@@ -668,25 +668,25 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
668668 * tp1 <:< tp2 using fourthTry (this might instantiate params in tp1)
669669 * tp1 <:< app2 using isSubType (this might instantiate params in tp2)
670670 */
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))
675677 }
676678
677679 tycon2 match {
678680 case param2 : PolyParam =>
679681 isMatchingApply(tp1) || {
680682 if (canConstrain(param2)) canInstantiate(param2)
681- else compareLower(bounds(param2))
683+ else compareLower(bounds(param2), tyconIsTypeRef = false )
682684 }
683685 case tycon2 : TypeRef =>
684686 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)
690690 case _ =>
691691 false
692692 }
@@ -706,7 +706,7 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling {
706706 canConstrain(param1) && canInstantiate ||
707707 isSubType(bounds(param1).hi.applyIfParameterized(args1), tp2)
708708 case tycon1 : TypeProxy =>
709- isSubType(tycon1 .superType.applyIfParameterized(args1) , tp2)
709+ isSubType(tp1 .superType, tp2)
710710 case _ =>
711711 false
712712 }
0 commit comments