Skip to content

Commit 07113f4

Browse files
committed
Small change
1 parent 2af5a6e commit 07113f4

File tree

6 files changed

+16
-14
lines changed

6 files changed

+16
-14
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
253253
case tp: MethodType =>
254254
val isParamDependent = tp.isParamDependent
255255
val previousParamRefs: ListBuffer[TermRef] =
256+
// It is ok to assign `null` here.
257+
// If `isParamDependent == false`, the value of `previousParamRefs` is not used.
256258
if isParamDependent then mutable.ListBuffer[TermRef]() else null.asInstanceOf
257259

258260
def valueParam(name: TermName, origInfo: Type): TermSymbol =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ object Constants {
160160
case TypeBounds(lo, hi) =>
161161
if (hi.classSymbol.isPrimitiveValueClass) hi //constrain further with high bound
162162
else classBound(lo)
163-
case NoType => classBound(param.binder.paramInfos(param.paramNum).lo) // TODO
163+
case NoType => classBound(param.binder.paramInfos(param.paramNum).lo)
164164
case inst => classBound(inst)
165165
}
166166
case pt => pt

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ object Contexts {
322322
related = SimpleIdentityMap.empty
323323
null
324324
else
325-
related.nn.apply(key)
325+
related.nn(key)
326326

327327
private def withPhase(phase: Phase, pid: PhaseId): Context =
328328
util.Stats.record("Context.withPhase")

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,7 @@ class Definitions {
12271227
val patches = patchCls.info.decls.filter(patch =>
12281228
!patch.isConstructor && !patch.isOneOf(PrivateOrSynthetic))
12291229
for patch <- patches if !recurse(patch) do
1230-
val e: ScopeEntry | Null = scope.lookupEntry(patch.name)
1230+
val e = scope.lookupEntry(patch.name)
12311231
if e != null then scope.unlink(e)
12321232
for patch <- patches do
12331233
patch.ensureCompleted()
@@ -1286,16 +1286,15 @@ class Definitions {
12861286
@tu lazy val TupleType: Array[TypeRef] = mkArityArray("scala.Tuple", MaxTupleArity, 1)
12871287

12881288
private class FunType(prefix: String):
1289-
private var classRefs: Array[TypeRef] = new Array(22)
1289+
private var classRefs: Array[TypeRef | Null] = new Array(22)
12901290
def apply(n: Int): TypeRef =
12911291
while n >= classRefs.length do
1292-
val classRefs1 = new Array[TypeRef](classRefs.length * 2)
1292+
val classRefs1 = new Array[TypeRef | Null](classRefs.length * 2)
12931293
Array.copy(classRefs, 0, classRefs1, 0, classRefs.length)
12941294
classRefs = classRefs1
1295-
val cr: TypeRef | Null = classRefs(n)
1296-
if cr == null then
1295+
if classRefs(n) == null then
12971296
classRefs(n) = requiredClassRef(prefix + n.toString)
1298-
classRefs(n)
1297+
classRefs(n).nn
12991298

13001299
private val erasedContextFunType = FunType("scala.ErasedContextFunction")
13011300
private val contextFunType = FunType("scala.ContextFunction")
@@ -1837,15 +1836,15 @@ class Definitions {
18371836

18381837
@tu lazy val reservedScalaClassNames: Set[Name] = syntheticScalaClasses.map(_.name).toSet
18391838

1840-
private var isDefnInitialized = false
1839+
private var isInitialized = false
18411840

18421841
def init()(using Context): Unit = {
18431842
this.initCtx = ctx
1844-
if (!isDefnInitialized) {
1843+
if (!isInitialized) {
18451844
// force initialization of every symbol that is synthesized or hijacked by the compiler
18461845
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses() :+ JavaEnumClass
18471846

1848-
isDefnInitialized = true
1847+
isInitialized = true
18491848
}
18501849
addSyntheticSymbolsComments
18511850
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ object Implicits:
274274
* @param companionRefs the companion objects in the implicit scope.
275275
*/
276276
class OfTypeImplicits(tp: Type, override val companionRefs: TermRefSet)(initctx: Context) extends ImplicitRefs(initctx) {
277-
// assert(initctx.typer != null)
277+
// TODO: do we need this assert?
278+
assert((initctx.typer: Typer | Null) != null)
278279
implicits.println(i"implicit scope of type $tp = ${companionRefs.showAsList}%, %")
279280
@threadUnsafe lazy val refs: List[ImplicitRef] = {
280281
val buf = new mutable.ListBuffer[TermRef]
@@ -1863,7 +1864,7 @@ sealed class TermRefSet(using Context):
18631864
if !that.isEmpty then that.foreach(+=)
18641865

18651866
def foreach[U](f: TermRef => U): Unit =
1866-
// TODO
1867+
// TODO: do we need to check sym == null?
18671868
def handle(sym: TermSymbol | Null, prefixes: Type | List[Type] | Null): Unit =
18681869
prefixes match
18691870
case prefix: Type => f(TermRef(prefix, sym.uncheckedNN))

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2799,7 +2799,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
27992799
object SourceFile extends SourceFileModule {
28002800
def current: SourceFile =
28012801
val unit = ctx.compilationUnit
2802-
if unit == NoCompilationUnit then
2802+
if unit eq NoCompilationUnit then
28032803
throw new java.lang.UnsupportedOperationException(
28042804
"`reflect.SourceFile.current` cannot be called within the TASTy ispector")
28052805
else unit.source

0 commit comments

Comments
 (0)