-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix warning message for matching on redundant nulls
- Loading branch information
Showing
3 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:10:7 ----------------------------------------- | ||
10 | case _: n.type => // warn | ||
| ^^^^^^^^^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:12:7 ----------------------------------------- | ||
12 | case _ => // warn | ||
| ^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:13:7 ----------------------------------------- | ||
13 | case _ => // warn | ||
| ^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:18:7 ----------------------------------------- | ||
18 | case _ => 3 // warn | ||
| ^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:23:7 ----------------------------------------- | ||
23 | case _: B => // warn | ||
| ^^^^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:24:7 ----------------------------------------- | ||
24 | case _ => // warn | ||
| ^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:25:7 ----------------------------------------- | ||
25 | case null => // warn | ||
| ^^^^ | ||
| Unreachable case | ||
-- [E121] Pattern Match Warning: tests/warn/redundant-null.scala:30:7 -------------------------------------------------- | ||
30 | case _ => // warn | ||
| ^ | ||
| Unreachable case except for null (if this is intentional, consider writing case null => instead). | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:31:7 ----------------------------------------- | ||
31 | case null => // warn | ||
| ^^^^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:32:7 ----------------------------------------- | ||
32 | case _ => // warn | ||
| ^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:33:7 ----------------------------------------- | ||
33 | case _ => // warn | ||
| ^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:37:7 ----------------------------------------- | ||
37 | case _ => println("unreachable") // warn | ||
| ^ | ||
| Unreachable case | ||
-- [E030] Match case Unreachable Warning: tests/warn/redundant-null.scala:41:7 ----------------------------------------- | ||
41 | case _ => // warn | ||
| ^ | ||
| Unreachable case |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class A | ||
class B | ||
class C | ||
|
||
val n = null | ||
|
||
def f(s: A) = s match | ||
case _: n.type => | ||
case _: A => | ||
case _: n.type => // warn | ||
case null => | ||
case _ => // warn | ||
case _ => // warn | ||
|
||
def f2(s: A | B | C) = s match | ||
case _: A => 0 | ||
case _: C | null | _: B => 1 | ||
case _ => 3 // warn | ||
|
||
def f3(s: A | B) = s match | ||
case _: A => | ||
case _ => | ||
case _: B => // warn | ||
case _ => // warn | ||
case null => // warn | ||
|
||
def f4(s: String | Int) = s match | ||
case _: Int => | ||
case _: String => | ||
case _ => // warn | ||
case null => // warn | ||
case _ => // warn | ||
case _ => // warn | ||
|
||
def f5(x: String) = x match | ||
case x => println("catch all") | ||
case _ => println("unreachable") // warn | ||
|
||
def test(s: String | Null) = s match | ||
case ss => | ||
case _ => // warn |