File tree Expand file tree Collapse file tree 3 files changed +22
-9
lines changed Expand file tree Collapse file tree 3 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 11class Foo {
2+
23 val s : String = ???
3- s match {
4- case s : String => 100 // warning: type test will always succeed
5- case _ => 200 // error: unreachable
6- }
74
85 s match {
9- case s : String => 100 // warning: type test will always succeed
6+ case s : String => 100
107 case _ => 200 // error: unreachable
118 }
129
@@ -15,20 +12,23 @@ class Foo {
1512 case object Cat extends Animal
1613
1714 val a : Animal = ???
15+
1816 a match {
1917 case Dog (name) => 100
2018 case Cat => 200
2119 case _ => 300 // error: unreachable
2220 }
2321
24- val a2 : Animal | Null = ???
22+ val a2 : Animal | Null = ???
23+
2524 a2 match {
2625 case Dog (_) => 100
2726 case Cat => 200
2827 case _ => 300
2928 }
3029
31- val a3 : Animal | Null = ???
30+ val a3 : Animal | Null = ???
31+
3232 a3 match {
3333 case Dog (_) => 100
3434 case Cat => 200
Original file line number Diff line number Diff line change 1+ import scala .language .unsafeNulls
2+
3+ def test1 =
4+ val s : String = ???
5+ s match
6+ case _ : String =>
7+ // under unsafeNulls, we should not get Match case Unreachable Warning
8+ case null => // ok
9+
10+ def test2 =
11+ val s : String | Null = ???
12+ s match
13+ case _ : String =>
14+ case null =>
Original file line number Diff line number Diff line change @@ -2,8 +2,7 @@ def test1 =
22 val s : String = ???
33 s match
44 case _ : String =>
5- // under unsafeNulls, we should not get Match case Unreachable Warning
6- case null => // error
5+ case null => // error: Values of types Null and String cannot be compared
76
87def test2 =
98 val s : String | Null = ???
You can’t perform that action at this time.
0 commit comments