@@ -1167,13 +1167,25 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
11671167 else
11681168 fallback(tycon2bounds.lo)
11691169
1170+ def byGadtBounds : Boolean =
1171+ {
1172+ tycon2 match
1173+ case tycon2 : TypeRef =>
1174+ val tycon2sym = tycon2.symbol
1175+ tycon2sym.onGadtBounds { bounds2 =>
1176+ inFrozenGadt { compareLower(bounds2, tyconIsTypeRef = false ) }
1177+ }
1178+ case _ => false
1179+ } && { GADTused = true ; true }
1180+
11701181 tycon2 match {
11711182 case param2 : TypeParamRef =>
11721183 isMatchingApply(tp1) ||
11731184 canConstrain(param2) && canInstantiate(param2) ||
11741185 compareLower(bounds(param2), tyconIsTypeRef = false )
11751186 case tycon2 : TypeRef =>
11761187 isMatchingApply(tp1) ||
1188+ byGadtBounds ||
11771189 defn.isCompiletimeAppliedType(tycon2.symbol) && compareCompiletimeAppliedType(tp2, tp1, fromBelow = true ) || {
11781190 tycon2.info match {
11791191 case info2 : TypeBounds =>
@@ -1213,11 +1225,18 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
12131225 isSubType(bounds(param1).hi.applyIfParameterized(args1), tp2, approx.addLow)
12141226 case tycon1 : TypeRef =>
12151227 val sym = tycon1.symbol
1228+
1229+ def byGadtBounds : Boolean =
1230+ sym.onGadtBounds { bounds1 =>
1231+ inFrozenGadt { isSubType(bounds1.hi.applyIfParameterized(args1), tp2, approx.addLow) }
1232+ } && { GADTused = true ; true }
1233+
1234+
12161235 ! sym.isClass && {
12171236 defn.isCompiletimeAppliedType(sym) && compareCompiletimeAppliedType(tp1, tp2, fromBelow = false ) ||
12181237 recur(tp1.superType, tp2) ||
12191238 tryLiftedToThis1
1220- }
1239+ }|| byGadtBounds
12211240 case tycon1 : TypeProxy =>
12221241 recur(tp1.superType, tp2)
12231242 case _ =>
0 commit comments