Skip to content

Commit 4eaab9b

Browse files
committed
fix scala#8956: add regression test
1 parent 345c8bc commit 4eaab9b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/pos/i8956.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
type Numeric = Double | Int
2+
3+
val v1 = 100
4+
val v2 = 100.0
5+
def check1(i: Double | Int | String): Unit = {
6+
i match {
7+
case a:(Double | Int) => println(s"numeric = $a")
8+
case _ => println("categorical")
9+
}
10+
}
11+
/*
12+
[warn] 25 | case a:Numeric => println(s"numeric = $a")
13+
[warn] | ^^^^^^^^^
14+
[warn] | the type test for gg.SlidingIssue.Numeric cannot be checked at runtime
15+
[warn] one warning found
16+
*/
17+
def check2(i: Double | Int | String): Unit = {
18+
i match {
19+
case a:Numeric => println(s"numeric = $a")
20+
case _ => println("categorical")
21+
}
22+
}

0 commit comments

Comments
 (0)