@@ -605,11 +605,11 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
605
605
if (tparams1.nonEmpty)
606
606
return recur(tp1.EtaExpand (tparams1), tp2) || fourthTry
607
607
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
610
610
case _ =>
611
+ fourthTry
611
612
}
612
- fourthTry
613
613
}
614
614
compareTypeLambda
615
615
case OrType (tp21, tp22) =>
@@ -773,7 +773,10 @@ class TypeComparer(initctx: Context) extends ConstraintHandling[AbsentContext] w
773
773
isNewSubType(tp1.parent)
774
774
case tp1 : HKTypeLambda =>
775
775
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)
777
780
case _ => tp2 match {
778
781
case tp2 : HKTypeLambda => false // this case was covered in thirdTry
779
782
case _ => tp2.typeParams.hasSameLengthAs(tp1.paramRefs) && isSubType(tp1.resultType, tp2.appliedTo(tp1.paramRefs))
@@ -2591,7 +2594,11 @@ class ExplainingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
2591
2594
}
2592
2595
2593
2596
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 " " }" ) {
2595
2602
super .isSubType(tp1, tp2, approx)
2596
2603
}
2597
2604
0 commit comments