Skip to content

Commit 3c3b323

Browse files
committed
Fix outer test in pattern matcher
Previous test did not reflect deeper paths for outer references. This caused a -Ycheck:patMat failure for i1269.scala.
1 parent 6e72320 commit 3c3b323

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/dotty/tools/dotc/transform/PatternMatcher.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -763,9 +763,8 @@ class PatternMatcher extends MiniPhaseTransform with DenotTransformer {thisTrans
763763

764764
def outerTest(testedBinder: Symbol, expectedTp: Type): Tree = {
765765
val expectedOuter = expectedTp.normalizedPrefix match {
766-
//case ThisType(clazz) => This(clazz)
767766
//case NoType => Literal(Constant(true)) // fallback for SI-6183 todo?
768-
case pre => ref(pre.termSymbol)
767+
case pre: SingletonType => singleton(pre)
769768
}
770769

771770
// ExplicitOuter replaces `Select(q, outerSym) OBJ_EQ expectedPrefix` by `Select(q, outerAccessor(outerSym.owner)) OBJ_EQ expectedPrefix`

tests/pos/i1269.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
trait Module {
2+
sealed abstract class Tree
3+
4+
case class LetL() extends Tree
5+
6+
object O {
7+
case class LetR() extends Tree
8+
}
9+
}
10+
11+
class Patmat(val module: Module) {
12+
def patmat(tree: module.Tree) = tree match {
13+
case module.LetL() =>
14+
case module.O.LetR() =>
15+
}
16+
}

0 commit comments

Comments
 (0)