Skip to content

Commit 056a0ad

Browse files
committed
Mark UnsafeJavaReturn as experimental
1 parent b7cf1be commit 056a0ad

File tree

10 files changed

+14
-10
lines changed

10 files changed

+14
-10
lines changed

compiler/src/dotty/tools/dotc/Run.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
368368
if ctx.settings.YexplicitNulls.value then
369369
if !Feature.enabledBySetting(nme.unsafeNulls) then
370370
start = start.addMode(Mode.SafeNulls)
371-
if Feature.enabledBySetting(nme.unsafeJavaReturn) then
371+
if Feature.enabledBySetting(Feature.unsafeJavaReturn) then
372372
start = start.addMode(Mode.UnsafeJavaReturn)
373373
ctx.initialize()(using start) // re-initialize the base context with start
374374

compiler/src/dotty/tools/dotc/config/Feature.scala

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ object Feature:
2828
val symbolLiterals = deprecated("symbolLiterals")
2929
val fewerBraces = experimental("fewerBraces")
3030
val saferExceptions = experimental("saferExceptions")
31+
val unsafeJavaReturn = experimental("unsafeJavaReturn")
3132

3233
/** Is `feature` enabled by by a command-line setting? The enabling setting is
3334
*

compiler/src/dotty/tools/dotc/core/Contexts.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import scala.io.Codec
2626
import collection.mutable
2727
import printing._
2828
import config.{JavaPlatform, SJSPlatform, Platform, ScalaSettings}
29+
import config.Feature
2930
import classfile.ReusableDataReader
3031
import StdNames.nme
3132

@@ -649,7 +650,7 @@ object Contexts {
649650
case Some(false) =>
650651
setMode(this.mode | Mode.SafeNulls)
651652
case _ =>
652-
importInfo.mentionsFeature(nme.unsafeJavaReturn) match
653+
importInfo.mentionsFeature(Feature.unsafeJavaReturn) match
653654
case Some(true) =>
654655
setMode(this.mode | Mode.UnsafeJavaReturn)
655656
case Some(false) =>

compiler/src/dotty/tools/dotc/core/StdNames.scala

-1
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,6 @@ object StdNames {
612612
val unapplySeq: N = "unapplySeq"
613613
val unbox: N = "unbox"
614614
val universe: N = "universe"
615-
val unsafeJavaReturn: N = "unsafeJavaReturn"
616615
val unsafeNulls: N = "unsafeNulls"
617616
val update: N = "update"
618617
val updateDynamic: N = "updateDynamic"

library/src/scala/annotation/CanEqualNull.scala

+1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ package scala.annotation
1818
* ss.map(_ == null)
1919
* ```
2020
*/
21+
@experimental
2122
final class CanEqualNull extends RefiningAnnotation

library/src/scala/runtime/stdLibPatches/language.scala

+5-3
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ object language:
6060
@compileTimeOnly("`saferExceptions` can only be used at compile time in import statements")
6161
object saferExceptions
6262

63+
/** Experimental support for unsafe Java return in explicit nulls
64+
*/
65+
@compileTimeOnly("`unsafeJavaReturn` can only be used at compile time in import statements")
66+
object unsafeJavaReturn
67+
6368
end experimental
6469

6570
/** The deprecated object contains features that are no longer officially suypported in Scala.
@@ -128,9 +133,6 @@ object language:
128133
@compileTimeOnly("`unsafeNulls` can only be used at compile time in import statements")
129134
object unsafeNulls
130135

131-
@compileTimeOnly("`unsafeJavaReturn` can only be used at compile time in import statements")
132-
object unsafeJavaReturn
133-
134136
@compileTimeOnly("`future` can only be used at compile time in import statements")
135137
object future
136138

tests/explicit-nulls/unsafe-java/JavaStatic.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import language.unsafeJavaReturn
1+
import language.experimental.unsafeJavaReturn
22

33
import java.math.MathContext, MathContext._
44

tests/explicit-nulls/unsafe-java/UnaryCall.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.language.unsafeJavaReturn
1+
import scala.language.experimental.unsafeJavaReturn
22

33
import java.lang.reflect.Method
44

tests/explicit-nulls/unsafe-java/java-chain/S.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.language.unsafeJavaReturn
1+
import scala.language.experimental.unsafeJavaReturn
22

33
def f = {
44
val j: J2 = new J2()

tests/explicit-nulls/unsafe-java/java-class/S.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.language.unsafeJavaReturn
1+
import scala.language.experimental.unsafeJavaReturn
22

33
import scala.annotation.CanEqualNull
44
import java.{util => ju}

0 commit comments

Comments
 (0)