diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-09-20 11:23:31 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-10-10 13:25:35 +0200 |
commit | 153c566d0d6ec8f2e55ab575e1e77f7881629cbc (patch) | |
tree | 2076c39234af213d93974bdc7b4ae155406ca77f /src/dotty/tools/dotc/repl/CompilingInterpreter.scala | |
parent | 6b12f65244964ba740d1a2c2ef7a0b6e3c7b5eb0 (diff) | |
download | dotty-153c566d0d6ec8f2e55ab575e1e77f7881629cbc.tar.gz dotty-153c566d0d6ec8f2e55ab575e1e77f7881629cbc.tar.bz2 dotty-153c566d0d6ec8f2e55ab575e1e77f7881629cbc.zip |
Fix multiple parsing errors on e.g. `try 1`
The `CompilingInterpreter` will on a single compile run, make multiple
parsings of the given line(s). This results in multiple warnings from
the parser. As such, clear the warnings until the actual compile is
performed.
Diffstat (limited to 'src/dotty/tools/dotc/repl/CompilingInterpreter.scala')
-rw-r--r-- | src/dotty/tools/dotc/repl/CompilingInterpreter.scala | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala index 0964de303..5b3669d5e 100644 --- a/src/dotty/tools/dotc/repl/CompilingInterpreter.scala +++ b/src/dotty/tools/dotc/repl/CompilingInterpreter.scala @@ -212,8 +212,10 @@ class CompilingInterpreter( case None => Interpreter.Incomplete case Some(Nil) => Interpreter.Error // parse error or empty input case Some(tree :: Nil) if tree.isTerm && !tree.isInstanceOf[Assign] => + previousOutput.clear() // clear previous error reporting interpret(s"val $newVarName =\n$line") case Some(trees) => + previousOutput.clear() // clear previous error reporting val req = new Request(line, newLineName) if (!req.compile()) Interpreter.Error // an error happened during compilation, e.g. a type error @@ -314,9 +316,13 @@ class CompilingInterpreter( /** One line of code submitted by the user for interpretation */ private class Request(val line: String, val lineName: String)(implicit ctx: Context) { - private val trees = parse(line) match { - case Some(ts) => ts - case None => Nil + private val trees = { + val parsed = parse(line) + previousOutput.clear() // clear previous error reporting + parsed match { + case Some(ts) => ts + case None => Nil + } } /** name to use for the object that will compute "line" */ |