Skip to content

Commit 7b07ad9

Browse files
committed
Cleaner initialization of InteractiveDriver
1 parent fb7d82c commit 7b07ad9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,15 +299,17 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
299299
}
300300

301301
/**
302-
* Initialize this driver and compiler by "compiling" a fake, empty source file.
302+
* Initialize this driver and compiler.
303303
*
304304
* This is necessary because an `InteractiveDriver` can be put to work without having
305305
* compiled anything (for instance, resolving a symbol coming from a different compiler in
306-
* this compiler). In those cases, an un-initialized compiler will crash.
306+
* this compiler). In those cases, an un-initialized compiler may crash (for instance if
307+
* late-compilation is needed).
307308
*/
308309
private[this] def initialize(): Unit = {
309-
val fakeSource = new File("fake.scala")
310-
run(fakeSource.toURI, "")
310+
val run = compiler.newRun(myInitCtx.fresh)
311+
myCtx = run.runContext
312+
run.compileUnits(Nil, myCtx)
311313
}
312314

313315
}

0 commit comments

Comments
 (0)