File tree 1 file changed +11
-2
lines changed
compiler/src/dotty/tools/dotc/core
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -254,7 +254,13 @@ trait PatternTypeConstrainer { self: TypeComparer =>
254
254
tyconS.typeParams.lazyZip(argsS).lazyZip(argsP).forall { (param, argS, argP) =>
255
255
val variance = param.paramVarianceSign
256
256
if variance != 0 && ! assumeInvariantRefinement then true
257
- else if argS.isInstanceOf [TypeBounds ] || argP.isInstanceOf [TypeBounds ] then true
257
+ else if argS.isInstanceOf [TypeBounds ] || argP.isInstanceOf [TypeBounds ] then
258
+ // Passing TypeBounds to isSubType on LHS or RHS does the
259
+ // incorrect thing and infers unsound constraints, while simply
260
+ // returning true is sound. However, I believe that it should
261
+ // still be possible to extract useful constraints here.
262
+ // TODO extract GADT information out of wildcard type arguments
263
+ true
258
264
else {
259
265
var res = true
260
266
if variance < 1 then res &&= isSubType(argS, argP)
@@ -267,7 +273,10 @@ trait PatternTypeConstrainer { self: TypeComparer =>
267
273
ctx.gadt.restore(savedGadt)
268
274
result
269
275
case _ =>
270
- // give up if we don't get AppliedType, e.g. if we upcasted to Any.
276
+ // Give up if we don't get AppliedType, e.g. if we upcasted to Any.
277
+ // Note that this doesn't mean that patternTp, scrutineeTp cannot possibly
278
+ // be co-inhabited, just that we cannot extract information out of them directly
279
+ // and should upcast.
271
280
false
272
281
}
273
282
}
You can’t perform that action at this time.
0 commit comments