File tree 3 files changed +36
-4
lines changed
compiler/src/dotty/tools/dotc/transform
3 files changed +36
-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
+ ok
2
+ ok
3
+ ok
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
+ type Foo = [Q ] =>> x2.Y [Q ]
11
+ type Bar = [Q ] =>> x1.Y [Q ]
12
+
13
+ @ main def Test () = {
14
+ b match {
15
+ case _ : a2.B => println(" wrong" )
16
+ case _ : a1.B => println(" ok" )
17
+ }
18
+ y match {
19
+ case _ : x2.Y [_] => println(" wrong" )
20
+ case _ : x1.Y [_] => println(" ok" )
21
+ }
22
+ y match {
23
+ case _ : Foo [_] => println(" wrong" )
24
+ case _ : Bar [_] => println(" ok" )
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments