-
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.
Merge pull request #13976 from dotty-staging/unsafe-nulls-fix-space
Fix case null on non-nullable type in unsafe nulls
- Loading branch information
Showing
6 changed files
with
39 additions
and
21 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
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
14 changes: 14 additions & 0 deletions
14
tests/explicit-nulls/pos-patmat/unsafe-match-null-pat.scala
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,14 @@ | ||
import scala.language.unsafeNulls | ||
|
||
def test1 = | ||
val s: String = ??? | ||
s match | ||
case _: String => | ||
// under unsafeNulls, we should not get Match case Unreachable Warning | ||
case null => // ok | ||
|
||
def test2 = | ||
val s: String | Null = ??? | ||
s match | ||
case _: String => | ||
case null => |
11 changes: 11 additions & 0 deletions
11
tests/explicit-nulls/unsafe-common/unsafe-match-null.scala
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,11 @@ | ||
def test1 = | ||
val s: String = ??? | ||
s match | ||
case _: String => | ||
case null => // error: Values of types Null and String cannot be compared | ||
|
||
def test2 = | ||
val s: String | Null = ??? | ||
s match | ||
case _: String => | ||
case null => |