forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
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 scala#15350 from dotty-staging/fix-check-ctx
Fix checking ctx to carry correct modes
- Loading branch information
Showing
13 changed files
with
152 additions
and
28 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
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
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 @@ | ||
enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMessageID]: | ||
|
||
case NoExplanationID // errorNumber: -1 | ||
case EmptyCatchOrFinallyBlockID extends ErrorMessageID(isActive = false) // errorNumber: 0 | ||
|
||
def errorNumber = ordinal - 1 | ||
|
||
enum Color(val rgb: Int): | ||
case Red extends Color(0xFF0000) | ||
case Green extends Color(0x00FF00) | ||
case Blue extends Color(0x0000FF) | ||
|
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,5 @@ | ||
// testNotNull can be inserted during PatternMatcher | ||
def f(xs: List[String]) = | ||
xs.zipWithIndex.collect { | ||
case (arg, idx) => idx | ||
} |
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,67 @@ | ||
def trim(x: String | Null): String = | ||
import scala.language.unsafeNulls | ||
// The type of `x.trim()` is `String | Null`. | ||
// Although `String | Null` conforms the expected type `String`, | ||
// we still need to cast the expression to the expected type here, | ||
// because outside the scope we don't have `unsafeNulls` anymore. | ||
x.trim() | ||
|
||
class TestDefs: | ||
|
||
def f1: String | Null = null | ||
def f2: Array[String | Null] | Null = null | ||
def f3: Array[String] | Null = null | ||
|
||
def h1a: String = | ||
import scala.language.unsafeNulls | ||
f1 | ||
|
||
def h1b: String | Null = | ||
import scala.language.unsafeNulls | ||
f1 | ||
|
||
def h2a: Array[String] = | ||
import scala.language.unsafeNulls | ||
f2 | ||
|
||
def h2b: Array[String | Null] = | ||
import scala.language.unsafeNulls | ||
f2 | ||
|
||
def h3a: Array[String] = | ||
import scala.language.unsafeNulls | ||
f3 | ||
|
||
def h3b: Array[String | Null] = | ||
import scala.language.unsafeNulls | ||
f3 | ||
|
||
class TestVals: | ||
|
||
val f1: String | Null = null | ||
val f2: Array[String | Null] | Null = null | ||
val f3: Array[String] | Null = null | ||
|
||
val h1a: String = | ||
import scala.language.unsafeNulls | ||
f1 | ||
|
||
val h1b: String | Null = | ||
import scala.language.unsafeNulls | ||
f1 | ||
|
||
val h2a: Array[String] = | ||
import scala.language.unsafeNulls | ||
f2 | ||
|
||
val h2b: Array[String | Null] = | ||
import scala.language.unsafeNulls | ||
f2 | ||
|
||
val h3a: Array[String] = | ||
import scala.language.unsafeNulls | ||
f3 | ||
|
||
val h3b: Array[String | Null] = | ||
import scala.language.unsafeNulls | ||
f3 |
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 |
---|---|---|
@@ -1,10 +1,21 @@ | ||
import java.nio.file.FileSystems | ||
import java.util.ArrayList | ||
|
||
def directorySeparator: String = | ||
import scala.language.unsafeNulls | ||
FileSystems.getDefault().getSeparator() | ||
class A: | ||
|
||
def directorySeparator: String = | ||
import scala.language.unsafeNulls | ||
FileSystems.getDefault().getSeparator() | ||
|
||
def getFirstOfFirst(xs: ArrayList[ArrayList[ArrayList[String]]]): String = | ||
import scala.language.unsafeNulls | ||
xs.get(0).get(0).get(0) | ||
|
||
def getFirstOfFirst(xs: ArrayList[ArrayList[ArrayList[String]]]): String = | ||
class B: | ||
import scala.language.unsafeNulls | ||
xs.get(0).get(0).get(0) | ||
|
||
def directorySeparator: String = | ||
FileSystems.getDefault().getSeparator() | ||
|
||
def getFirstOfFirst(xs: ArrayList[ArrayList[ArrayList[String]]]): String = | ||
xs.get(0).get(0).get(0) |