Skip to content

Commit

Permalink
Merge pull request scala#14894 from dotty-staging/fix-11097
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand authored Apr 14, 2022
2 parents 93fc41f + 60d7d6c commit c084b46
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ object TypeTestsCasts {
case OrType(tp1, tp2) => recur(X, tp1) && recur(X, tp2)
case AnnotatedType(t, _) => recur(X, t)
case tp2: RefinedType => recur(X, tp2.parent) && TypeComparer.hasMatchingMember(tp2.refinedName, X, tp2)
case tp2: RecType => recur(X, tp2.parent)
case _ => true
})

Expand Down
13 changes: 13 additions & 0 deletions tests/neg-custom-args/fatal-warnings/i11097.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@main def test: Unit = {
class C { type T1; type T2 }

def pmatch(s: C): s.T2 = s match {
case p: (C { type T1 = Int; type T2 >: T1 } & s.type) => // error
(3: p.T1): p.T2
case p: (C { type T1 = String; type T2 >: T1 } & s.type) => // error
("this branch should be matched": p.T1): p.T2
}

// ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String
val x = pmatch(new C { type T1 = String; type T2 = String })
}

0 comments on commit c084b46

Please sign in to comment.