Skip to content

Commit 2f7c107

Browse files
authored
Merge pull request #15688 from dwijnand/gadt/wildcards
Fix constraining against HKTypeLambda arguments
2 parents 5c43324 + b6987cc commit 2f7c107

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,10 @@ trait PatternTypeConstrainer { self: TypeComparer =>
275275
argP.typeSymbol.isPatternBound && patternTp.classSymbol == scrutineeTp.classSymbol
276276
then
277277
val TypeBounds(loS, hiS) = argS.bounds
278+
val TypeBounds(loP, hiP) = argP.bounds
278279
var res = true
279-
if variance < 1 then res &&= isSubType(loS, argP)
280-
if variance > -1 then res &&= isSubType(argP, hiS)
280+
if variance < 1 then res &&= isSubType(loS, hiP)
281+
if variance > -1 then res &&= isSubType(loP, hiS)
281282
res
282283
else true
283284
}

tests/pos/i15677.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Inv[A]
2+
3+
class Foo[B, M[_]]
4+
5+
class Bar[C, N[_]] extends Foo[C, N]:
6+
def inv: Inv[C] = null
7+
8+
def test(foo: Foo[Int, Option]): Inv[Int] = foo match
9+
case bar: Bar[_, _] => bar.inv
10+
case _ => null

0 commit comments

Comments
 (0)