aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/repl/CompilingInterpreter.scala38
-rw-r--r--src/dotty/tools/dotc/repl/Interpreter.scala2
-rw-r--r--src/dotty/tools/dotc/repl/InterpreterLoop.scala6
3 files changed, 24 insertions, 22 deletions
diff --git a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
index d322aa404..b3b7ab13c 100644
--- a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
+++ b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
@@ -80,15 +80,13 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit
private var printResults: Boolean = true
private var delayOutput: Boolean = false
- var previousOutput: String = null
-
- override def lastOutput() =
- if (previousOutput == null) None
- else {
- val ret = Some(previousOutput)
- previousOutput = null
- ret
- }
+ var previousOutput: List[String] = Nil
+
+ override def lastOutput() = {
+ val prev = previousOutput
+ previousOutput = Nil
+ prev
+ }
override def delayOutputDuring[T](operation: => T): T = {
val old = delayOutput
@@ -113,14 +111,18 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit
private def newReporter = new ConsoleReporter(Console.in, out) {
override def printMessage(msg: String) = {
- out.print(/*clean*/(msg) + "\n")
- // Suppress clean for now for compiler messages
- // Otherwise we will completely delete all references to
- // line$object$ module classes. The previous interpreter did not
- // have the project because the module class was written without the final `$'
- // and therefore escaped the purge. We can turn this back on once
- // we drop the final `$' from module classes.
- out.flush()
+ if (!delayOutput) {
+ out.print(/*clean*/(msg) + "\n")
+ // Suppress clean for now for compiler messages
+ // Otherwise we will completely delete all references to
+ // line$object$ module classes. The previous interpreter did not
+ // have the project because the module class was written without the final `$'
+ // and therefore escaped the purge. We can turn this back on once
+ // we drop the final `$' from module classes.
+ out.flush()
+ } else {
+ previousOutput = (/*clean*/(msg) + "\n") :: previousOutput
+ }
}
}
@@ -210,7 +212,7 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit
else {
val (interpreterResultString, succeeded) = req.loadAndRun()
if (delayOutput)
- previousOutput = clean(interpreterResultString)
+ previousOutput = clean(interpreterResultString) :: previousOutput
else if (printResults || !succeeded)
out.print(clean(interpreterResultString))
if (succeeded) {
diff --git a/src/dotty/tools/dotc/repl/Interpreter.scala b/src/dotty/tools/dotc/repl/Interpreter.scala
index 590baae0d..6a292dfe2 100644
--- a/src/dotty/tools/dotc/repl/Interpreter.scala
+++ b/src/dotty/tools/dotc/repl/Interpreter.scala
@@ -38,5 +38,5 @@ trait Interpreter {
def delayOutputDuring[T](operation: => T): T
/** Gets the last output not printed immediately */
- def lastOutput(): Option[String]
+ def lastOutput(): List[String]
}
diff --git a/src/dotty/tools/dotc/repl/InterpreterLoop.scala b/src/dotty/tools/dotc/repl/InterpreterLoop.scala
index 98e47b635..c6c750b56 100644
--- a/src/dotty/tools/dotc/repl/InterpreterLoop.scala
+++ b/src/dotty/tools/dotc/repl/InterpreterLoop.scala
@@ -167,10 +167,10 @@ class InterpreterLoop(compiler: Compiler, config: REPL.Config)(implicit ctx: Con
output.println("Unknown command. Type :help for help.")
else
shouldReplay = interpreter.lastOutput() match { // don't interpret twice
- case Some(oldRes) =>
- output.print(oldRes)
+ case Nil => interpretStartingWith(line)
+ case oldRes =>
+ oldRes foreach output.print
Some(line)
- case None => interpretStartingWith(line)
}
(true, shouldReplay)