File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 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 =>
254254 tyconS.typeParams.lazyZip(argsS).lazyZip(argsP).forall { (param, argS, argP) =>
255255 val variance = param.paramVarianceSign
256256 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
258264 else {
259265 var res = true
260266 if variance < 1 then res &&= isSubType(argS, argP)
@@ -267,7 +273,10 @@ trait PatternTypeConstrainer { self: TypeComparer =>
267273 ctx.gadt.restore(savedGadt)
268274 result
269275 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.
271280 false
272281 }
273282 }
You can’t perform that action at this time.
0 commit comments