File tree 3 files changed +29
-4
lines changed
compiler/src/dotty/tools/dotc/transform 3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -719,16 +719,19 @@ object PatternMatcher {
719
719
val expectedTp = tpt.tpe
720
720
721
721
// An outer test is needed in a situation like `case x: y.Inner => ...`
722
- def outerTestNeeded : Boolean =
723
- // See the test for SI-7214 for motivation for dealias. Later `treeCondStrategy#outerTest`
724
- // generates an outer test based on `patType.prefix` with automatically dealises.
725
- expectedTp.dealias match {
722
+ def outerTestNeeded : Boolean = {
723
+ def go (expected : Type ): Boolean = expected match {
726
724
case tref @ TypeRef (pre : SingletonType , _) =>
727
725
tref.symbol.isClass &&
728
726
ExplicitOuter .needsOuterIfReferenced(tref.symbol.asClass)
727
+ case AppliedType (tpe, _) => go(tpe)
729
728
case _ =>
730
729
false
731
730
}
731
+ // See the test for SI-7214 for motivation for dealias. Later `treeCondStrategy#outerTest`
732
+ // generates an outer test based on `patType.prefix` with automatically dealises.
733
+ go(expectedTp.dealias)
734
+ }
732
735
733
736
def outerTest : Tree = thisPhase.transformFollowingDeep {
734
737
val expectedOuter = singleton(expectedTp.normalizedPrefix)
Original file line number Diff line number Diff line change
1
+ no match
2
+ no match
Original file line number Diff line number Diff line change
1
+ class A { class B }
2
+ val a1 = new A
3
+ val a2 = new A
4
+ val b : Any = new a1.B
5
+
6
+ class X { class Y [Q ] }
7
+ val x1 = new X
8
+ val x2 = new X
9
+ val y : Any = new x1.Y [Int ]
10
+
11
+ @ main def Test () = {
12
+ b match {
13
+ case _ : a2.B => println(" match" )
14
+ case _ => println(" no match" )
15
+ }
16
+ y match {
17
+ case _ : x2.Y [_] => println(" match" )
18
+ case _ => println(" no match" )
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments