Skip to content

Commit 784864d

Browse files
committed
Warm up interpreter during first prompt.
1 parent ae5bccd commit 784864d

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/dotty/tools/dotc/repl/InterpreterLoop.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,13 @@ class InterpreterLoop(
7373
val version = ".next (pre-alpha)"
7474

7575
/** The first interpreted command always takes a couple of seconds
76-
* due to classloading. To bridge the gap, wait until the welcome message
77-
* has been printed before calling bindSettings. That way,
78-
* the user can read the welcome message while this
79-
* command executes.
76+
* due to classloading. To bridge the gap, we warm up the interpreter
77+
* by letting it interpret a dummy line while waiting for the first
78+
* line of input to be entered.
8079
*/
8180
def firstLine(): String = {
8281
val futLine = Future(in.readLine(prompt))
83-
// bindSettings() // TODO adapt to dotty and re-enable (?)
82+
interpreter.beQuietDuring(interpreter.interpret("val __$__ = 1 + 1"))
8483
Await.result(futLine, Duration.Inf)
8584
}
8685

src/dotty/tools/dotc/repl/Main.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package repl
1717
* - figure out why we can launch REPL only with `java`, not with `scala`.
1818
* - make a doti command (urgent, easy)
1919
* - create or port REPL tests (urgent, intermediate)
20-
* - make interpreter run a pseudo line on startup to pre-load compiler (somewhat urgent, easy)
2120
* - copy improvements of current Scala REPL wrt to this version
2221
* (somewhat urgent, intermediate)
2322
* - re-enable bindSettings (not urgent, easy, see TODO in InterpreterLoop.scala)

0 commit comments

Comments
 (0)