Skip to content

Commit 21c9336

Browse files
dwijnandmichelou
authored andcommitted
Extract wildcard GADT constraints more directly
1 parent 0d06e37 commit 21c9336

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

compiler/src/dotty/tools/dotc/core/PatternTypeConstrainer.scala

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -255,18 +255,11 @@ trait PatternTypeConstrainer { self: TypeComparer =>
255255
tyconS.typeParams.lazyZip(argsS).lazyZip(argsP).forall { (param, argS, argP) =>
256256
val variance = param.paramVarianceSign
257257
if variance != 0 && !assumeInvariantRefinement then true
258-
else if argS.isInstanceOf[TypeBounds] || argP.isInstanceOf[TypeBounds] then
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)
266258
else {
259+
val TypeBounds(loS, hiS) = argS.bounds
267260
var res = true
268-
if variance < 1 then res &&= isSubType(argS, argP)
269-
if variance > -1 then res &&= isSubType(argP, argS)
261+
if variance < 1 then res &&= isSubType(loS, argP)
262+
if variance > -1 then res &&= isSubType(argP, hiS)
270263
res
271264
}
272265
}

0 commit comments

Comments
 (0)