@@ -668,25 +668,25 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
668
668
* tp1 <:< tp2 using fourthTry (this might instantiate params in tp1)
669
669
* tp1 <:< app2 using isSubType (this might instantiate params in tp2)
670
670
*/
671
- def compareLower (tycon2bounds : TypeBounds ): Boolean = {
672
- val app2 = tycon2bounds.lo.applyIfParameterized(args2)
673
- if (tycon2bounds.lo eq tycon2bounds.hi) isSubType(tp1, app2)
674
- else either(fourthTry(tp1, tp2), isSubType(tp1, app2))
671
+ def compareLower (tycon2bounds : TypeBounds , tyconIsTypeRef : Boolean ): Boolean = {
672
+ def app2 = tycon2bounds.lo.applyIfParameterized(args2)
673
+ if (tycon2bounds.lo eq tycon2bounds.hi)
674
+ isSubType(tp1, if (tyconIsTypeRef) tp2.superType else app2)
675
+ else
676
+ either(fourthTry(tp1, tp2), isSubType(tp1, app2))
675
677
}
676
678
677
679
tycon2 match {
678
680
case param2 : PolyParam =>
679
681
isMatchingApply(tp1) || {
680
682
if (canConstrain(param2)) canInstantiate(param2)
681
- else compareLower(bounds(param2))
683
+ else compareLower(bounds(param2), tyconIsTypeRef = false )
682
684
}
683
685
case tycon2 : TypeRef =>
684
686
isMatchingApply(tp1) ||
685
- compareLower(tycon2.info.bounds)
686
- case tycon2 : TypeVar =>
687
- isSubType(tp1, tycon2.underlying.appliedTo(args2))
688
- case tycon2 : AnnotatedType =>
689
- compareHkApply2(tp1, tp2, tycon2.underlying, args2)
687
+ compareLower(tycon2.info.bounds, tyconIsTypeRef = true )
688
+ case _ : TypeVar | _ : AnnotatedType =>
689
+ isSubType(tp1, tp2.superType)
690
690
case _ =>
691
691
false
692
692
}
@@ -706,7 +706,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
706
706
canConstrain(param1) && canInstantiate ||
707
707
isSubType(bounds(param1).hi.applyIfParameterized(args1), tp2)
708
708
case tycon1 : TypeProxy =>
709
- isSubType(tycon1 .superType.applyIfParameterized(args1) , tp2)
709
+ isSubType(tp1 .superType, tp2)
710
710
case _ =>
711
711
false
712
712
}
0 commit comments