Skip to content

Commit c084b46

Browse files
authored
Merge pull request #14894 from dotty-staging/fix-11097
2 parents 93fc41f + 60d7d6c commit c084b46

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

compiler/src/dotty/tools/dotc/transform/TypeTestsCasts.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ object TypeTestsCasts {
151151
case OrType(tp1, tp2) => recur(X, tp1) && recur(X, tp2)
152152
case AnnotatedType(t, _) => recur(X, t)
153153
case tp2: RefinedType => recur(X, tp2.parent) && TypeComparer.hasMatchingMember(tp2.refinedName, X, tp2)
154+
case tp2: RecType => recur(X, tp2.parent)
154155
case _ => true
155156
})
156157

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@main def test: Unit = {
2+
class C { type T1; type T2 }
3+
4+
def pmatch(s: C): s.T2 = s match {
5+
case p: (C { type T1 = Int; type T2 >: T1 } & s.type) => // error
6+
(3: p.T1): p.T2
7+
case p: (C { type T1 = String; type T2 >: T1 } & s.type) => // error
8+
("this branch should be matched": p.T1): p.T2
9+
}
10+
11+
// ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String
12+
val x = pmatch(new C { type T1 = String; type T2 = String })
13+
}

0 commit comments

Comments
 (0)