Skip to content

Commit a217872

Browse files
committed
clean code
1 parent cfe683f commit a217872

File tree

8 files changed

+9
-24
lines changed

8 files changed

+9
-24
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ import Periods._
77
import Symbols._
88
import Types._
99
import Scopes._
10-
import StdNames.nme
1110
import Names.Name
1211
import Denotations.Denotation
1312
import typer.Typer
1413
import typer.ImportInfo._
1514
import Decorators._
1615
import io.{AbstractFile, PlainFile, VirtualFile}
1716
import Phases.unfusedPhases
18-
import config.Feature
1917

2018
import util._
2119
import reporting.Reporter

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@ import core._
1010
import util.Spans._, Types._, Contexts._, Constants._, Names._, Flags._, NameOps._
1111
import Symbols._, StdNames._, Annotations._, Trees._, Symbols._
1212
import Decorators._, DenotTransformers._
13-
import Phases._
1413
import collection.{immutable, mutable}
1514
import util.{Property, SourceFile, NoSource}
1615
import NameKinds.{TempResultName, OuterSelectName}
1716
import typer.ConstFold
18-
import typer.Nullables
1917

2018
import scala.annotation.tailrec
2119
import scala.io.Codec
@@ -471,7 +469,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
471469

472470
/** The wrapped array method name for an array of type elemtp */
473471
def wrapArrayMethodName(elemtp: Type)(using Context): TermName = {
474-
val elemCls = atPhase(erasurePhase.next) { elemtp.classSymbol }
472+
val elemCls = elemtp.classSymbol
475473
if (elemCls.isPrimitiveValueClass) nme.wrapXArray(elemCls.name)
476474
else if (elemCls.derivesFrom(defn.ObjectClass) && !elemCls.isNotRuntimeClass) nme.wrapRefArray
477475
else nme.genericWrapArray

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,4 +211,4 @@ class CheckRealizable(using Context) {
211211
else
212212
Realizable
213213
}
214-
}
214+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import Nullables._
2020
import Implicits.ContextualImplicits
2121
import config.Settings._
2222
import config.Config
23-
import config.Feature
2423
import reporting._
2524
import io.{AbstractFile, NoAbstractFile, PlainFile, Path}
2625
import scala.io.Codec
@@ -29,6 +28,7 @@ import printing._
2928
import config.{JavaPlatform, SJSPlatform, Platform, ScalaSettings}
3029
import classfile.ReusableDataReader
3130
import StdNames.nme
31+
3232
import scala.annotation.internal.sharable
3333

3434
import DenotTransformers.DenotTransformer

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1218,7 +1218,8 @@ class Definitions {
12181218
idx == name.length || name(idx).isDigit && digitsOnlyAfter(name, idx + 1)
12191219

12201220
def isBottomClass(cls: Symbol): Boolean =
1221-
if ctx.explicitNulls && !ctx.phase.erasedTypes then cls == NothingClass
1221+
if ctx.mode.is(Mode.SafeNulls) && !ctx.phase.erasedTypes
1222+
then cls == NothingClass
12221223
else isBottomClassAfterErasure(cls)
12231224

12241225
def isBottomClassAfterErasure(cls: Symbol): Boolean = cls == NothingClass || cls == NullClass

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,4 @@ object Mode {
127127
* This mode forces expansion of inline calls in those positions even during typing.
128128
*/
129129
val ForceInline: Mode = newMode(29, "ForceInline")
130-
131-
/** Should we use Unsafe Nulls SubTyping in TypeComparer?
132-
* If this mode is in the Context, `Null` is considered as a
133-
* subtype of all reference type.
134-
*/
135-
val UnsafeNullsSubType: Mode = newMode(30, "UnsafeNullsSubType")
136130
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -761,11 +761,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
761761
isSubType(hi1, tp2, approx.addLow) || compareGADT || tryLiftedToThis1
762762
case _ =>
763763
def isNullable(tp: Type): Boolean = tp.widenDealias match {
764-
case tp: TypeRef =>
765-
if ctx.explicitNulls && ctx.mode.is(Mode.UnsafeNullsSubType) then
766-
tp.symbol.isNullableClassAfterErasure
767-
else
768-
tp.symbol.isNullableClass
764+
case tp: TypeRef => tp.symbol.isNullableClass
769765
case tp: RefinedOrRecType => isNullable(tp.parent)
770766
case tp: AppliedType => isNullable(tp.tycon)
771767
case AndType(tp1, tp2) => isNullable(tp1) && isNullable(tp2)

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -797,11 +797,9 @@ class Typer extends Namer
797797
// A sequence argument `xs: _*` can be either a `Seq[T]` or an `Array[_ <: T]`,
798798
// irrespective of whether the method we're calling is a Java or Scala method,
799799
// so the expected type is the union `Seq[T] | Array[_ <: T]`.
800-
// If unsafe nulls is enabled, the expected type is `Seq[T | Null] | Array[_ <: T | Null] | Null`.
801-
val unsafeNulls = Nullables.unsafeNullsEnabled
802800
val ptArg =
803801
// FIXME(#8680): Quoted patterns do not support Array repeated arguments
804-
if (ctx.mode.is(Mode.QuotedPattern))
802+
if ctx.mode.is(Mode.QuotedPattern) then
805803
pt.translateFromRepeated(toArray = false, translateWildcard = true)
806804
else
807805
pt.translateFromRepeated(toArray = false, translateWildcard = true)
@@ -815,7 +813,7 @@ class Typer extends Namer
815813
// We need to make sure its type is no longer nullable
816814
expr0.castToNonNullable
817815
else expr0
818-
val fromCls = if expr1.tpe.stripNull.derivesFrom(defn.ArrayClass)
816+
val fromCls = if expr1.tpe.derivesFrom(defn.ArrayClass)
819817
then defn.ArrayClass else defn.SeqClass
820818
val tpt1 = TypeTree(expr1.tpe.widen.translateToRepeated(fromCls)).withSpan(tree.tpt.span)
821819
assignType(cpy.Typed(tree)(expr1, tpt1), tpt1)
@@ -3866,4 +3864,4 @@ class Typer extends Namer
38663864
EmptyTree
38673865
else typedExpr(call, defn.AnyType)
38683866

3869-
}
3867+
}

0 commit comments

Comments
 (0)