aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-04-27 13:38:38 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-04-28 11:00:39 +0200
commit57670a38ca55cc04c9d765bdf04584cad5581d41 (patch)
tree0ebfbf8c55749bd27cb97f1f536647c6f63b015a /src/dotty/tools/dotc/repl/CompilingInterpreter.scala
parentd04984596c6abfa27b217b12a42caca26f0c269f (diff)
downloaddotty-57670a38ca55cc04c9d765bdf04584cad5581d41.tar.gz
dotty-57670a38ca55cc04c9d765bdf04584cad5581d41.tar.bz2
dotty-57670a38ca55cc04c9d765bdf04584cad5581d41.zip
Stop interpreter from interpreting twice on enter
Diffstat (limited to 'src/dotty/tools/dotc/repl/CompilingInterpreter.scala')
-rw-r--r--src/dotty/tools/dotc/repl/CompilingInterpreter.scala25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
index cfcce106e..d322aa404 100644
--- a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
+++ b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala
@@ -78,6 +78,27 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit
/** whether to print out result lines */
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
+ }
+
+ override def delayOutputDuring[T](operation: => T): T = {
+ val old = delayOutput
+ try {
+ delayOutput = true
+ operation
+ } finally {
+ delayOutput = old
+ }
+ }
/** Temporarily be quiet */
override def beQuietDuring[T](operation: => T): T = {
@@ -188,7 +209,9 @@ class CompilingInterpreter(out: PrintWriter, ictx: Context) extends Compiler wit
Interpreter.Error // an error happened during compilation, e.g. a type error
else {
val (interpreterResultString, succeeded) = req.loadAndRun()
- if (printResults || !succeeded)
+ if (delayOutput)
+ previousOutput = clean(interpreterResultString)
+ else if (printResults || !succeeded)
out.print(clean(interpreterResultString))
if (succeeded) {
prevRequests += req