Skip to content

Commit 12a7286

Browse files
committed
Change ctx.importInfo to nullable
1 parent 92c9c55 commit 12a7286

File tree

7 files changed

+18
-18
lines changed

7 files changed

+18
-18
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ object Feature:
5151
*/
5252
def enabledByImport(feature: TermName)(using Context): Boolean =
5353
//atPhase(typerPhase) {
54-
val info: ImportInfo | Null = ctx.importInfo
54+
val info = ctx.importInfo
5555
info != null && info.featureImported(feature)
5656
//}
5757

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object Contexts {
5252
private val (runLoc, store6) = store5.newLocation[Run | Null]()
5353
private val (profilerLoc, store7) = store6.newLocation[Profiler]()
5454
private val (notNullInfosLoc, store8) = store7.newLocation[List[NotNullInfo]]()
55-
private val (importInfoLoc, store9) = store8.newLocation[ImportInfo]()
55+
private val (importInfoLoc, store9) = store8.newLocation[ImportInfo | Null]()
5656
private val (typeAssignerLoc, store10) = store9.newLocation[TypeAssigner](TypeAssigner)
5757

5858
private val initialStore = store10
@@ -233,10 +233,10 @@ object Contexts {
233233
def profiler: Profiler = store(profilerLoc)
234234

235235
/** The paths currently known to be not null */
236-
def notNullInfos = store(notNullInfosLoc)
236+
def notNullInfos: List[NotNullInfo] = store(notNullInfosLoc)
237237

238238
/** The currently active import info */
239-
def importInfo = store(importInfoLoc)
239+
def importInfo: ImportInfo | Null = store(importInfoLoc)
240240

241241
/** The current type assigner or typer */
242242
def typeAssigner: TypeAssigner = store(typeAssignerLoc)
@@ -252,12 +252,12 @@ object Contexts {
252252
catch {
253253
case ex: CyclicReference => Nil
254254
}
255-
else if (isImportContext) importInfo.importedImplicits
255+
else if (isImportContext) importInfo.nn.importedImplicits
256256
else if (isNonEmptyScopeContext) scope.implicitDecls
257257
else Nil
258258
val outerImplicits =
259-
if (isImportContext && importInfo.unimported.exists)
260-
outer.implicits exclude importInfo.unimported
259+
if (isImportContext && importInfo.nn.unimported.exists)
260+
outer.implicits exclude importInfo.nn.unimported
261261
else
262262
outer.implicits
263263
if (implicitRefs.isEmpty) outerImplicits
@@ -401,7 +401,7 @@ object Contexts {
401401
def isImportContext: Boolean =
402402
(this ne NoContext)
403403
&& (outer ne NoContext)
404-
&& (this.importInfo ne outer.importInfo)
404+
&& (this.importInfo nen outer.importInfo)
405405

406406
/** Is this a context that introduces a non-empty scope? */
407407
def isNonEmptyScopeContext: Boolean =
@@ -563,7 +563,7 @@ object Contexts {
563563

564564
override def toString: String =
565565
def iinfo(using Context) =
566-
val info: ImportInfo | Null = ctx.importInfo
566+
val info = ctx.importInfo
567567
if (info == null) "" else i"${info.selectors}%, %"
568568
def cinfo(using Context) =
569569
val core = s" owner = ${ctx.owner}, scope = ${ctx.scope}, import = $iinfo"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ object Implicits:
384384
if (this == NoContext.implicits) this
385385
else {
386386
val outerExcluded = outerImplicits.uncheckedNN exclude root
387-
if (irefCtx.importInfo.site.termSymbol == root) outerExcluded
387+
if (irefCtx.importInfo.nn.site.termSymbol == root) outerExcluded
388388
else if (outerExcluded eqn outerImplicits) this
389389
else new ContextualImplicits(refs, outerExcluded, isImport)(irefCtx)
390390
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ class ImportInfo(symf: Context ?=> Symbol,
218218
case Some(bv) => bv
219219
case None =>
220220
var c = ctx.outer
221-
while c.importInfo eq ctx.importInfo do c = c.outer
222-
// TODO: Do we need to change importInfo to nullable?
223-
((c.importInfo: ImportInfo | Null) != null) && c.importInfo.featureImported(feature)(using c)
221+
while c.importInfo eqn ctx.importInfo do c = c.outer
222+
val cinfo = c.importInfo
223+
(cinfo != null) && cinfo.featureImported(feature)(using c)
224224
)
225225
featureCache(feature).nn
226226

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ trait ImportSuggestions:
123123
.filter(lookInside(_))
124124
.flatMap(sym => rootsIn(sym.termRef))
125125
val imported =
126-
if ctx.importInfo eq ctx.outer.importInfo then Nil
127-
else ctx.importInfo.importSym.info match
126+
if ctx.importInfo eqn ctx.outer.importInfo then Nil
127+
else ctx.importInfo.nn.importSym.info match
128128
case ImportType(expr) => rootsOnPath(expr.tpe)
129129
case _ => Nil
130130
defined ++ imported ++ recur(using ctx.outer)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,12 +429,12 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
429429
if result.exists then result
430430
else { // find import
431431
val outer = ctx.outer
432-
val curImport: ImportInfo | Null = ctx.importInfo
432+
val curImport = ctx.importInfo
433433
def updateUnimported() =
434434
if (curImport.nn.unimported ne NoSymbol) unimported += curImport.nn.unimported
435435
if (curOwner.is(Package) && curImport != null && curImport.isRootImport && previous.exists)
436436
previous // no more conflicts possible in this case
437-
else if (isPossibleImport(NamedImport) && (curImport.uncheckedNN ne outer.importInfo)) {
437+
else if (isPossibleImport(NamedImport) && (curImport nen outer.importInfo)) {
438438
val namedImp = namedImportRef(curImport.uncheckedNN)
439439
if (namedImp.exists)
440440
recurAndCheckNewOrShadowed(namedImp, NamedImport, ctx)(using outer)

compiler/test/dotty/tools/dotc/interactive/CustomCompletionTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class CustomCompletionTests extends DottyTest:
4343
given ctx: Context = run.runContext.withSource(file)
4444
val unit = CompilationUnit(file)
4545
ctx
46-
.run
46+
.run.nn
4747
.compileUnits(unit :: Nil, ctx)
4848

4949
// ignoring compilation errors here - the input code

0 commit comments

Comments
 (0)