Skip to content

Commit 5539aea

Browse files
authored
Merge pull request #11522 from Linyxus/fix-gadt-strip-refinement
Fix refinement stripping in GADT constrainer
2 parents ca7c6fc + bbb717c commit 5539aea

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ trait PatternTypeConstrainer { self: TypeComparer =>
140140
either(constrainPatternType(pat1, scrut), constrainPatternType(pat2, scrut))
141141
case AndType(pat1, pat2) =>
142142
constrainPatternType(pat1, scrut) && constrainPatternType(pat2, scrut)
143-
case scrut: RefinedOrRecType =>
144-
constrainPatternType(stripRefinement(scrut), pat)
143+
case pat: RefinedOrRecType =>
144+
constrainPatternType(stripRefinement(pat), scrut)
145145
case pat =>
146146
constrainSimplePatternType(pat, scrut) || classesMayBeCompatible && constrainUpcasted(scrut)
147147
}

tests/pos/gadt-strip-refinement.scala

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
trait Tag[T] { type X }
2+
class IntTag extends Tag[Int]
3+
4+
def foo[T](x: Tag[T]): T = x match {
5+
case _: IntTag { type X = String } => 0
6+
}

0 commit comments

Comments
 (0)