Skip to content

Commit

Permalink
Merge pull request #15757 from dotty-staging/backport-15688
Browse files Browse the repository at this point in the history
Backport #15688: Fix constraining against HKTypeLambda arguments
  • Loading branch information
Kordyjan authored Jul 27, 2022
2 parents 25bbcba + 04b9e6e commit 86aa1e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,10 @@ trait PatternTypeConstrainer { self: TypeComparer =>
argP.typeSymbol.isPatternBound && patternTp.classSymbol == scrutineeTp.classSymbol
then
val TypeBounds(loS, hiS) = argS.bounds
val TypeBounds(loP, hiP) = argP.bounds
var res = true
if variance < 1 then res &&= isSubType(loS, argP)
if variance > -1 then res &&= isSubType(argP, hiS)
if variance < 1 then res &&= isSubType(loS, hiP)
if variance > -1 then res &&= isSubType(loP, hiS)
res
else true
}
Expand Down
10 changes: 10 additions & 0 deletions tests/pos/i15677.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Inv[A]

class Foo[B, M[_]]

class Bar[C, N[_]] extends Foo[C, N]:
def inv: Inv[C] = null

def test(foo: Foo[Int, Option]): Inv[Int] = foo match
case bar: Bar[_, _] => bar.inv
case _ => null

0 comments on commit 86aa1e4

Please sign in to comment.