@@ -58,8 +58,8 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
58
58
59
59
private var compiling = false
60
60
61
- private var myUnits : List [CompilationUnit ] = _
62
- private var myUnitsCached : List [CompilationUnit ] = _
61
+ private var myUnits : List [CompilationUnit ] = Nil
62
+ private var myUnitsCached : List [CompilationUnit ] = Nil
63
63
private var myFiles : Set [AbstractFile ] = _
64
64
65
65
// `@nowarn` annotations by source file, populated during typer
@@ -73,7 +73,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
73
73
// When the REPL creates a new run (ReplDriver.compile), parsing is already done in the old context, with the
74
74
// previous Run. Parser warnings were suspended in the old run and need to be copied over so they are not lost.
75
75
// Same as scala/scala/commit/79ca1408c7.
76
- def initSuspendedMessages (oldRun : Run ) = if oldRun != null then
76
+ def initSuspendedMessages (oldRun : Run | Null ) = if oldRun != null then
77
77
mySuspendedMessages.clear()
78
78
mySuspendedMessages ++= oldRun.mySuspendedMessages
79
79
@@ -170,7 +170,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
170
170
compileSources(sources)
171
171
catch
172
172
case NonFatal (ex) =>
173
- if units != null then report.echo(i " exception occurred while compiling $units%, % " )
173
+ if units.nonEmpty then report.echo(i " exception occurred while compiling $units%, % " )
174
174
else report.echo(s " exception occurred while compiling ${files.map(_.name).mkString(" , " )}" )
175
175
throw ex
176
176
@@ -309,7 +309,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
309
309
val uuid = java.util.UUID .randomUUID().toString
310
310
val ext = if (isJava) " .java" else " .scala"
311
311
val virtualFile = new VirtualFile (s " compileFromString- $uuid. $ext" )
312
- val writer = new BufferedWriter (new OutputStreamWriter (virtualFile.output, StandardCharsets .UTF_8 .name)) // buffering is still advised by javadoc
312
+ val writer = new BufferedWriter (new OutputStreamWriter (virtualFile.output, StandardCharsets .UTF_8 .nn. name)) // buffering is still advised by javadoc
313
313
writer.write(source)
314
314
writer.close()
315
315
new SourceFile (virtualFile, Codec .UTF8 )
@@ -333,8 +333,8 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
333
333
super [ImplicitRunInfo ].reset()
334
334
super [ConstraintRunInfo ].reset()
335
335
myCtx = null
336
- myUnits = null
337
- myUnitsCached = null
336
+ myUnits = Nil
337
+ myUnitsCached = Nil
338
338
}
339
339
340
340
/** Produces the following contexts, from outermost to innermost
@@ -367,9 +367,9 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
367
367
start.setRun(this : @ unchecked)
368
368
}
369
369
370
- private var myCtx = rootContext(using ictx)
370
+ private var myCtx : Context | Null = rootContext(using ictx)
371
371
372
372
/** The context created for this run */
373
- given runContext [Dummy_so_its_a_def ]: Context = myCtx
373
+ given runContext [Dummy_so_its_a_def ]: Context = myCtx.nn
374
374
assert(runContext.runId <= Periods .MaxPossibleRunId )
375
375
}
0 commit comments