-
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.
Improve warning for wildcard matching only null under explicit nulls …
…(scala#21577) Adds a more detailed warning message when a wildcard case is only reachable by null under explict nulls flag. Fixes scala#21577
- Loading branch information
Showing
4 changed files
with
52 additions
and
5 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
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,12 @@ | ||
-- [E121] Pattern Match Warning: tests/explicit-nulls/warn/i21577.scala:5:9 -------------------------------------------- | ||
5 | case _ => println(2) // warn | ||
| ^ | ||
| Unreachable case except for null (if this is intentional, consider writing case null => instead). | ||
-- [E121] Pattern Match Warning: tests/explicit-nulls/warn/i21577.scala:12:11 ------------------------------------------ | ||
12 | case _ => println(2) // warn | ||
| ^ | ||
| Unreachable case except for null (if this is intentional, consider writing case null => instead). | ||
-- [E121] Pattern Match Warning: tests/explicit-nulls/warn/i21577.scala:18:11 ------------------------------------------ | ||
18 | case _ => println(2) // warn | ||
| ^ | ||
| Unreachable case except for null (if this is intentional, consider writing case null => instead). |
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,24 @@ | ||
def f(s: String) = | ||
val s2 = s.trim() | ||
s2 match | ||
case s3: String => println(1) | ||
case _ => println(2) // warn | ||
|
||
|
||
def f2(s: String | Null) = | ||
val s2 = s.nn.trim() | ||
s2 match | ||
case s3: String => println(1) | ||
case _ => println(2) // warn | ||
|
||
def f3(s: String | Null) = | ||
val s2 = s | ||
s2 match | ||
case s3: String => println(1) | ||
case _ => println(2) // warn | ||
|
||
def f4(s: String | Int) = | ||
val s2 = s | ||
s2 match | ||
case s3: String => println(1) | ||
case _ => println(2) |