File tree 3 files changed +22
-9
lines changed
3 files changed +22
-9
lines changed Original file line number Diff line number Diff line change 1
1
class Foo {
2
+
2
3
val s : String = ???
3
- s match {
4
- case s : String => 100 // warning: type test will always succeed
5
- case _ => 200 // error: unreachable
6
- }
7
4
8
5
s match {
9
- case s : String => 100 // warning: type test will always succeed
6
+ case s : String => 100
10
7
case _ => 200 // error: unreachable
11
8
}
12
9
@@ -15,20 +12,23 @@ class Foo {
15
12
case object Cat extends Animal
16
13
17
14
val a : Animal = ???
15
+
18
16
a match {
19
17
case Dog (name) => 100
20
18
case Cat => 200
21
19
case _ => 300 // error: unreachable
22
20
}
23
21
24
- val a2 : Animal | Null = ???
22
+ val a2 : Animal | Null = ???
23
+
25
24
a2 match {
26
25
case Dog (_) => 100
27
26
case Cat => 200
28
27
case _ => 300
29
28
}
30
29
31
- val a3 : Animal | Null = ???
30
+ val a3 : Animal | Null = ???
31
+
32
32
a3 match {
33
33
case Dog (_) => 100
34
34
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 =
2
2
val s : String = ???
3
3
s match
4
4
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
7
6
8
7
def test2 =
9
8
val s : String | Null = ???
You can’t perform that action at this time.
0 commit comments