@@ -1167,13 +1167,25 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1167
1167
else
1168
1168
fallback(tycon2bounds.lo)
1169
1169
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
+
1170
1181
tycon2 match {
1171
1182
case param2 : TypeParamRef =>
1172
1183
isMatchingApply(tp1) ||
1173
1184
canConstrain(param2) && canInstantiate(param2) ||
1174
1185
compareLower(bounds(param2), tyconIsTypeRef = false )
1175
1186
case tycon2 : TypeRef =>
1176
1187
isMatchingApply(tp1) ||
1188
+ byGadtBounds ||
1177
1189
defn.isCompiletimeAppliedType(tycon2.symbol) && compareCompiletimeAppliedType(tp2, tp1, fromBelow = true ) || {
1178
1190
tycon2.info match {
1179
1191
case info2 : TypeBounds =>
@@ -1213,11 +1225,18 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
1213
1225
isSubType(bounds(param1).hi.applyIfParameterized(args1), tp2, approx.addLow)
1214
1226
case tycon1 : TypeRef =>
1215
1227
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
+
1216
1235
! sym.isClass && {
1217
1236
defn.isCompiletimeAppliedType(sym) && compareCompiletimeAppliedType(tp1, tp2, fromBelow = false ) ||
1218
1237
recur(tp1.superType, tp2) ||
1219
1238
tryLiftedToThis1
1220
- }
1239
+ }|| byGadtBounds
1221
1240
case tycon1 : TypeProxy =>
1222
1241
recur(tp1.superType, tp2)
1223
1242
case _ =>
0 commit comments