Skip to content

Commit aa6e0ed

Browse files
committed
Seperate Java Compatible part
1 parent 04ac722 commit aa6e0ed

File tree

8 files changed

+9
-51
lines changed

8 files changed

+9
-51
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ class ScalaSettings extends Settings.SettingGroup {
170170
// Extremely experimental language features
171171
val YnoKindPolymorphism: Setting[Boolean] = BooleanSetting("-Yno-kind-polymorphism", "Disable kind polymorphism.")
172172
val YexplicitNulls: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls", "Make reference types non-nullable. Nullable types can be expressed with unions: e.g. String|Null.")
173-
val YexplicitNullsJavaCompatible: Setting[Boolean] = BooleanSetting("-Yexplicit-nulls-java", "explicit-nulls-java")
174173
val YerasedTerms: Setting[Boolean] = BooleanSetting("-Yerased-terms", "Allows the use of erased terms.")
175174
val YcheckInit: Setting[Boolean] = BooleanSetting("-Ycheck-init", "Check initialization of objects")
176175

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,8 +478,6 @@ object Contexts {
478478
/** Is the explicit nulls option set? */
479479
def explicitNulls: Boolean = base.settings.YexplicitNulls.value
480480

481-
def explicitNullsJavaCompatible: Boolean = base.settings.YexplicitNullsJavaCompatible.value
482-
483481
/** Initialize all context fields, except typerState, which has to be set separately
484482
* @param outer The outer context
485483
* @param origin The context from which fields are copied

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,4 @@ object Mode {
114114
val QuotedPattern: Mode = newMode(25, "QuotedPattern")
115115

116116
val UnsafeNullConversion: Mode = newMode(26, "UnsafeNullConversion")
117-
118-
val UnsafeNullConversionJava: Mode = newMode(27, "UnsafeNullConversionJava")
119117
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,13 +739,11 @@ object Types {
739739
go(l).meet(go(r), pre, safeIntersection = ctx.base.pendingMemberSearches.contains(name))
740740

741741
def goOr(tp: OrType) = tp match {
742-
case OrNull(tp1) if ctx.explicitNullsJavaCompatible || config.Feature.enabled(nme.unsafeNulls) =>
742+
case OrNull(tp1) if config.Feature.enabled(nme.unsafeNulls) =>
743743
// Selecting `name` from a type `T | Null` is like selecting `name` from `T`, if
744744
// unsafeNulls is enabled. This can throw at runtime, but we trade soundness for usability.
745745
val d = tp1.findMember(name, pre.stripNull, required, excluded)
746-
if config.Feature.enabled(nme.unsafeNulls) ||
747-
(ctx.explicitNullsJavaCompatible && d.symbol.is(JavaDefined))
748-
then d
746+
if config.Feature.enabled(nme.unsafeNulls) then d
749747
else go(tp.join)
750748
case _ =>
751749
// we need to keep the invariant that `pre <: tp`. Branch `union-types-narrow-prefix`

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -889,14 +889,7 @@ trait Applications extends Compatibility {
889889
def simpleApply(fun1: Tree, proto: FunProto)(using Context): Tree =
890890
methPart(fun1).tpe match {
891891
case funRef: TermRef =>
892-
val argsCtx =
893-
if ctx.explicitNulls && ctx.explicitNullsJavaCompatible then
894-
if funRef.symbol.is(JavaDefined) then
895-
ctx.addMode(Mode.UnsafeNullConversionJava)
896-
else
897-
ctx.retractMode(Mode.UnsafeNullConversionJava)
898-
else ctx
899-
val app = ApplyTo(tree, fun1, funRef, proto, pt)(using argsCtx)
892+
val app = ApplyTo(tree, fun1, funRef, proto, pt)
900893
convertNewGenericArray(
901894
postProcessByNameArgs(funRef, app).computeNullable())
902895
case _ =>

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -364,23 +364,16 @@ object ProtoTypes {
364364
/** Type single argument and remember the unadapted result in `myTypedArg`.
365365
* used to avoid repeated typings of trees when backtracking.
366366
*/
367-
def typedArg(arg: untpd.Tree, formal: Type)(using Context): Tree = {
367+
def typedArg(arg: untpd.Tree, formal: Type)(using Context): Tree = {
368368
val wideFormal = formal.widenExpr
369-
val javaCallUnsafeNull = ctx.mode.is(Mode.UnsafeNullConversionJava)
370369
val argCtx =
371370
if wideFormal eq formal then ctx
372371
else ctx.withNotNullInfos(ctx.notNullInfos.retractMutables)
373-
val adaptCtx = if javaCallUnsafeNull then ctx.addMode(Mode.UnsafeNullConversion) else ctx
374372
val locked = ctx.typerState.ownedVars
375-
val targ = if javaCallUnsafeNull then
376-
cacheTypedArg(arg,
377-
typer.typedUnadaptedWithBlock(_, wideFormal, locked)(using argCtx.retractMode(Mode.UnsafeNullConversionJava)),
378-
force = true)
379-
else
380-
cacheTypedArg(arg,
381-
typer.typedUnadapted(_, wideFormal, locked)(using argCtx),
382-
force = true)
383-
typer.adapt(targ, wideFormal, locked)(using adaptCtx)
373+
val targ = cacheTypedArg(arg,
374+
typer.typedUnadapted(_, wideFormal, locked)(using argCtx),
375+
force = true)
376+
typer.adapt(targ, wideFormal, locked)
384377
}
385378

386379
/** The type of the argument `arg`, or `NoType` if `arg` has not been typed before

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3567,13 +3567,8 @@ class Typer extends Namer
35673567
tree
35683568
else recover(failure.reason)
35693569

3570-
val javaCompatibleCall = ctx.explicitNullsJavaCompatible && (tree match {
3571-
case Apply(_, _) => tree.symbol.is(JavaDefined)
3572-
case _ => false
3573-
})
3574-
35753570
val searchCtx =
3576-
if ctx.explicitNulls && (javaCompatibleCall || config.Feature.enabled(nme.unsafeNulls)) then
3571+
if ctx.explicitNulls && config.Feature.enabled(nme.unsafeNulls) then
35773572
ctx.addMode(Mode.UnsafeNullConversion)
35783573
else ctx
35793574

tests/explicit-nulls/pos-java-compatible/select.scala

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)