Skip to content

Commit 0d52503

Browse files
committed
Small change
1 parent 1d886e3 commit 0d52503

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
@@ -1215,7 +1215,7 @@ class Definitions {
12151215
val patches = patchCls.info.decls.filter(patch =>
12161216
!patch.isConstructor && !patch.isOneOf(PrivateOrSynthetic))
12171217
for patch <- patches if !recurse(patch) do
1218-
val e: ScopeEntry | Null = scope.lookupEntry(patch.name)
1218+
val e = scope.lookupEntry(patch.name)
12191219
if e != null then scope.unlink(e)
12201220
for patch <- patches do
12211221
patch.ensureCompleted()
@@ -1274,16 +1274,15 @@ class Definitions {
12741274
@tu lazy val TupleType: Array[TypeRef] = mkArityArray("scala.Tuple", MaxTupleArity, 1)
12751275

12761276
private class FunType(prefix: String):
1277-
private var classRefs: Array[TypeRef] = new Array(22)
1277+
private var classRefs: Array[TypeRef | Null] = new Array(22)
12781278
def apply(n: Int): TypeRef =
12791279
while n >= classRefs.length do
1280-
val classRefs1 = new Array[TypeRef](classRefs.length * 2)
1280+
val classRefs1 = new Array[TypeRef | Null](classRefs.length * 2)
12811281
Array.copy(classRefs, 0, classRefs1, 0, classRefs.length)
12821282
classRefs = classRefs1
1283-
val cr: TypeRef | Null = classRefs(n)
1284-
if cr == null then
1283+
if classRefs(n) == null then
12851284
classRefs(n) = requiredClassRef(prefix + n.toString)
1286-
classRefs(n)
1285+
classRefs(n).nn
12871286

12881287
private val erasedContextFunType = FunType("scala.ErasedContextFunction")
12891288
private val contextFunType = FunType("scala.ContextFunction")
@@ -1822,15 +1821,15 @@ class Definitions {
18221821

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

1825-
private var isDefnInitialized = false
1824+
private var isInitialized = false
18261825

18271826
def init()(using Context): Unit = {
18281827
this.initCtx = ctx
1829-
if (!isDefnInitialized) {
1828+
if (!isInitialized) {
18301829
// force initialization of every symbol that is synthesized or hijacked by the compiler
18311830
val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses() :+ JavaEnumClass
18321831

1833-
isDefnInitialized = true
1832+
isInitialized = true
18341833
}
18351834
addSyntheticSymbolsComments
18361835
}

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)