File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -256,12 +256,13 @@ trait PatternTypeConstrainer { self: TypeComparer =>
256256 val variance = param.paramVarianceSign
257257 if variance != 0 && ! assumeInvariantRefinement then true
258258 else if argS.isInstanceOf [TypeBounds ] || argP.isInstanceOf [TypeBounds ] then
259- // Passing TypeBounds to isSubType on LHS or RHS does the
260- // incorrect thing and infers unsound constraints, while simply
261- // returning true is sound. However, I believe that it should
262- // still be possible to extract useful constraints here.
263- // TODO extract GADT information out of wildcard type arguments
264- true
259+ // This line was added here as a quick fix for issue #13998,
260+ // to extract GADT constraints from wildcard type arguments.
261+ // The proper fix would involve inspecting the bounds right here and performing the
262+ // correct subtyping checks, the ones that are already performed by `isSubType` below,
263+ // for the same reasons for which we stopped using `SkolemType` here to begin with
264+ // (commit 10fe5374dc2d).
265+ isSubType(SkolemType (patternTp), scrutineeTp)
265266 else {
266267 var res = true
267268 if variance < 1 then res &&= isSubType(argS, argP)
Original file line number Diff line number Diff line change 1+ case class Box [V ](value : V )
2+ object Box :
3+ def apply [A ](a : A ): Box [A ] = new Box [A ](a)
4+ def unapply [U ](b : Box [U ]): Box [U ] = b
5+
6+ class Test :
7+ def value : Box [_ <: String ] = Box (" text" )
8+
9+ def test : String = value match
10+ case Box (text) => text : String
You can’t perform that action at this time.
0 commit comments