Skip to content

Commit 92c9c55

Browse files
committed
Change ctx.run to nullable
1 parent 2492300 commit 92c9c55

File tree

20 files changed

+40
-37
lines changed

20 files changed

+40
-37
lines changed

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class GenBCode extends Phase {
7575
try super.runOn(units)
7676
finally outputDir match {
7777
case jar: JarArchive =>
78-
if (ctx.run.suspendedUnits.nonEmpty)
78+
if (ctx.run.nn.suspendedUnits.nonEmpty)
7979
// If we close the jar the next run will not be able to write on the jar.
8080
// But if we do not close it we cannot use it as part of the macro classpath of the suspended files.
8181
report.error("Can not suspend and output to a jar at the same time. See suspension with -Xprint-suspension.")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class CompilationUnit protected (val source: SourceFile) {
7171
if (ctx.settings.XprintSuspension.value)
7272
report.echo(i"suspended: $this")
7373
suspended = true
74-
ctx.run.suspendedUnits += this
74+
ctx.run.nn.suspendedUnits += this
7575
if ctx.phase == Phases.inliningPhase then
7676
suspendedAtInliningPhase = true
7777
throw CompilationUnit.SuspendException()

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ class Compiler {
152152

153153
def reset()(using Context): Unit = {
154154
ctx.base.reset()
155-
val run: Run | Null = ctx.run
155+
val run = ctx.run
156156
if (run != null) run.reset()
157157
}
158158

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ object Contexts {
4949
private val (printerFnLoc, store3) = store2.newLocation[Context => Printer](new RefinedPrinter(_))
5050
private val (settingsStateLoc, store4) = store3.newLocation[SettingsState]()
5151
private val (compilationUnitLoc, store5) = store4.newLocation[CompilationUnit]()
52-
private val (runLoc, store6) = store5.newLocation[Run]()
52+
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]]()
5555
private val (importInfoLoc, store9) = store8.newLocation[ImportInfo]()
@@ -227,7 +227,7 @@ object Contexts {
227227
def compilationUnit: CompilationUnit = store(compilationUnitLoc)
228228

229229
/** The current compiler-run */
230-
def run: Run = store(runLoc)
230+
def run: Run | Null = store(runLoc)
231231

232232
/** The current compiler-run profiler */
233233
def profiler: Profiler = store(profilerLoc)
@@ -655,7 +655,7 @@ object Contexts {
655655
def setSbtCallback(callback: AnalysisCallback): this.type = updateStore(sbtCallbackLoc, callback)
656656
def setPrinterFn(printer: Context => Printer): this.type = updateStore(printerFnLoc, printer)
657657
def setSettings(settingsState: SettingsState): this.type = updateStore(settingsStateLoc, settingsState)
658-
def setRun(run: Run): this.type = updateStore(runLoc, run)
658+
def setRun(run: Run | Null): this.type = updateStore(runLoc, run)
659659
def setProfiler(profiler: Profiler): this.type = updateStore(profilerLoc, profiler)
660660
def setNotNullInfos(notNullInfos: List[NotNullInfo]): this.type = updateStore(notNullInfosLoc, notNullInfos)
661661
def setImportInfo(importInfo: ImportInfo): this.type =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,7 @@ object Denotations {
13181318
recurSimple(path.length, wrap)
13191319
}
13201320

1321-
val run: Run | Null = ctx.run
1321+
val run = ctx.run
13221322
if run == null then recur(path)
13231323
else run.staticRefs.getOrElseUpdate(path, recur(path))
13241324
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object OrderingConstraint {
2929
empty
3030
else
3131
val result = new OrderingConstraint(boundsMap, lowerMap, upperMap)
32-
ctx.run.recordConstraintSize(result, result.boundsMap.size)
32+
ctx.run.nn.recordConstraintSize(result, result.boundsMap.size)
3333
result
3434

3535
/** A lens for updating a single entry array in one of the three constraint maps */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ class SourcefileLoader(val srcfile: AbstractFile) extends SymbolLoader {
426426
def description(using Context): String = "source file " + srcfile.toString
427427
override def sourceFileOrNull: AbstractFile | Null = srcfile
428428
def doComplete(root: SymDenotation)(using Context): Unit =
429-
ctx.run.lateCompile(srcfile, typeCheck = ctx.settings.YretainTrees.value)
429+
ctx.run.nn.lateCompile(srcfile, typeCheck = ctx.settings.YretainTrees.value)
430430
}
431431

432432
/** A NoCompleter which is also a SymbolLoader. */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ object Symbols {
142142

143143
/** Does this symbol come from a currently compiled source file? */
144144
final def isDefinedInCurrentRun(using Context): Boolean =
145-
span.exists && defRunId == ctx.runId && associatedFileMatches(ctx.run.files.contains)
145+
span.exists && defRunId == ctx.runId && associatedFileMatches(ctx.run.nn.files.contains)
146146

147147
/** Is this symbol valid in the current run and has an associated file that is
148148
* not a binary file. e.g. This will return true for

compiler/src/dotty/tools/dotc/decompiler/IDEDecompilerDriver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class IDEDecompilerDriver(val settings: List[String]) extends dotc.Driver {
3737
inContext(run.runContext) {
3838
run.compile(List(tastyFile))
3939
run.printSummary()
40-
val unit = ctx.run.units.head
40+
val unit = ctx.run.nn.units.head
4141

4242
val decompiled = QuotesImpl.showDecompiledTree(unit.tpdTree)
4343
val tree = new TastyHTMLPrinter(unit.pickled.head._2()).showContents()

compiler/src/dotty/tools/dotc/interactive/Completion.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ object Completion {
353353
val extMethodsFromGivensInScope = extractMemberExtensionMethods(givensInScope)
354354

355355
// 3. The reference is of the form r.m and the extension method is defined in the implicit scope of the type of r.
356-
val implicitScopeCompanions = ctx.run.implicitScope(qual.tpe).companionRefs.showAsList
356+
val implicitScopeCompanions = ctx.run.nn.implicitScope(qual.tpe).companionRefs.showAsList
357357
val extMethodsFromImplicitScope = extractMemberExtensionMethods(implicitScopeCompanions)
358358

359359
// 4. The reference is of the form r.m and the extension method is defined in some given instance in the implicit scope of the type of r.

0 commit comments

Comments
 (0)