@@ -605,11 +605,11 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
605605 if (tparams1.nonEmpty)
606606 return recur(tp1.EtaExpand (tparams1), tp2) || fourthTry
607607 tp2 match {
608- case EtaExpansion (tycon2) if tycon2.symbol.isClass =>
609- return recur(tp1, tycon2)
608+ case EtaExpansion (tycon2) if tycon2.symbol.isClass && tycon2.symbol.is( JavaDefined ) =>
609+ recur(tp1, tycon2) || fourthTry
610610 case _ =>
611+ fourthTry
611612 }
612- fourthTry
613613 }
614614 compareTypeLambda
615615 case OrType (tp21, tp22) =>
@@ -773,7 +773,10 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
773773 isNewSubType(tp1.parent)
774774 case tp1 : HKTypeLambda =>
775775 def compareHKLambda = tp1 match {
776- case EtaExpansion (tycon1) => recur(tycon1, tp2)
776+ case EtaExpansion (tycon1) if tycon1.symbol.isClass && tycon1.symbol.is(JavaDefined ) =>
777+ // It's a raw type that was mistakenly eta-expanded to a hk-type.
778+ // This can happen because we do not cook types coming from Java sources
779+ recur(tycon1, tp2)
777780 case _ => tp2 match {
778781 case tp2 : HKTypeLambda => false // this case was covered in thirdTry
779782 case _ => tp2.typeParams.hasSameLengthAs(tp1.paramRefs) && isSubType(tp1.resultType, tp2.appliedTo(tp1.paramRefs))
@@ -2591,7 +2594,11 @@ class ExplainingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
25912594 }
25922595
25932596 override def isSubType (tp1 : Type , tp2 : Type , approx : ApproxState ): Boolean =
2594- traceIndented(s " ${show(tp1)} <:< ${show(tp2)}${if (Config .verboseExplainSubtype) s " ${tp1.getClass} ${tp2.getClass}" else " " } $approx ${if (frozenConstraint) " frozen" else " " }" ) {
2597+ def moreInfo =
2598+ if Config .verboseExplainSubtype || ctx.settings.verbose.value
2599+ then s " ${tp1.getClass} ${tp2.getClass}"
2600+ else " "
2601+ traceIndented(s " ${show(tp1)} <:< ${show(tp2)}$moreInfo $approx ${if (frozenConstraint) " frozen" else " " }" ) {
25952602 super .isSubType(tp1, tp2, approx)
25962603 }
25972604
0 commit comments