11package dotty .tools
22package dotc
33
4+ import scala .language .{unsafeNulls => _ }
5+
46import core ._
57import Contexts ._
68import Periods ._
@@ -59,8 +61,8 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
5961
6062 private var compiling = false
6163
62- private var myUnits : List [CompilationUnit ] = _
63- private var myUnitsCached : List [CompilationUnit ] = _
64+ private var myUnits : List [CompilationUnit ] = Nil
65+ private var myUnitsCached : List [CompilationUnit ] = Nil
6466 private var myFiles : Set [AbstractFile ] = _
6567
6668 // `@nowarn` annotations by source file, populated during typer
@@ -74,7 +76,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
7476 // When the REPL creates a new run (ReplDriver.compile), parsing is already done in the old context, with the
7577 // previous Run. Parser warnings were suspended in the old run and need to be copied over so they are not lost.
7678 // Same as scala/scala/commit/79ca1408c7.
77- def initSuspendedMessages (oldRun : Run ) = if oldRun != null then
79+ def initSuspendedMessages (oldRun : Run | Null ) = if oldRun != null then
7880 mySuspendedMessages.clear()
7981 mySuspendedMessages ++= oldRun.mySuspendedMessages
8082
@@ -171,7 +173,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
171173 compileSources(sources)
172174 catch
173175 case NonFatal (ex) =>
174- if units != null then report.echo(i " exception occurred while compiling $units%, % " )
176+ if units != Nil then report.echo(i " exception occurred while compiling $units%, % " )
175177 else report.echo(s " exception occurred while compiling ${files.map(_.name).mkString(" , " )}" )
176178 throw ex
177179
@@ -310,7 +312,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
310312 val uuid = java.util.UUID .randomUUID().toString
311313 val ext = if (isJava) " .java" else " .scala"
312314 val virtualFile = new VirtualFile (s " compileFromString- $uuid. $ext" )
313- val writer = new BufferedWriter (new OutputStreamWriter (virtualFile.output, StandardCharsets .UTF_8 .name)) // buffering is still advised by javadoc
315+ val writer = new BufferedWriter (new OutputStreamWriter (virtualFile.output, StandardCharsets .UTF_8 .nn. name)) // buffering is still advised by javadoc
314316 writer.write(source)
315317 writer.close()
316318 new SourceFile (virtualFile, Codec .UTF8 )
@@ -333,8 +335,8 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
333335 super [ImplicitRunInfo ].reset()
334336 super [ConstraintRunInfo ].reset()
335337 myCtx = null
336- myUnits = null
337- myUnitsCached = null
338+ myUnits = Nil
339+ myUnitsCached = Nil
338340 }
339341
340342 /** Produces the following contexts, from outermost to innermost
@@ -367,9 +369,9 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
367369 start.setRun(this : @ unchecked)
368370 }
369371
370- private var myCtx = rootContext(using ictx)
372+ private var myCtx : Context | Null = rootContext(using ictx)
371373
372374 /** The context created for this run */
373- given runContext [Dummy_so_its_a_def ]: Context = myCtx
375+ given runContext [Dummy_so_its_a_def ]: Context = myCtx.nn
374376 assert(runContext.runId <= Periods .MaxPossibleRunId )
375377}
0 commit comments