Skip to content

Commit a2576d8

Browse files
Add original issue test
Fixes #23435
1 parent 1151958 commit a2576d8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/neg/i23435-min.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
type Or[+A, +B] = A | B
3+
4+
val x: Or[Int, String] & Or[String, Int] = 3
5+
val y: Or[Int & String, Int & String] = x // error
6+
val z: Int & String = y

tests/neg/i23435.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
trait L[+A]{val a:A}
3+
trait R[+B]{val b: B}
4+
5+
class LR(val a: Int, val b: String) extends L[Int] with R[String]
6+
7+
type E[+A] = L[A] | R[A]
8+
9+
val x: E[Int] & E[String] = LR(4, "hi")
10+
val y: E[Int&String] = x // error
11+
12+
val z = y match
13+
case l : L[Int&String] => l.a
14+
case r : R[Int&String] => r.b
15+
16+
val _ = z:String // was: java.lang.ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String

0 commit comments

Comments
 (0)