diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-10-13 08:17:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-13 08:17:47 +0200 |
commit | a90a7845ef5fb44d842dc316de2c4fdc52946b41 (patch) | |
tree | 54b0d28ce5ab845d127b85ac8fa74ed348dd774f /src/dotty/tools/dotc | |
parent | 1c62d0557417612fb90108fd6a3728d7c510f968 (diff) | |
parent | 7f2b7d48f416ecdca97f021e75c0a049374b1daf (diff) | |
download | dotty-a90a7845ef5fb44d842dc316de2c4fdc52946b41.tar.gz dotty-a90a7845ef5fb44d842dc316de2c4fdc52946b41.tar.bz2 dotty-a90a7845ef5fb44d842dc316de2c4fdc52946b41.zip |
Merge pull request #1585 from dos65/repl_file_loading
Fix #1552: REPL file loading
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/repl/InterpreterLoop.scala | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/src/dotty/tools/dotc/repl/InterpreterLoop.scala b/src/dotty/tools/dotc/repl/InterpreterLoop.scala index 7e5dcc7f1..8b1000f2e 100644 --- a/src/dotty/tools/dotc/repl/InterpreterLoop.scala +++ b/src/dotty/tools/dotc/repl/InterpreterLoop.scala @@ -83,25 +83,16 @@ class InterpreterLoop(compiler: Compiler, config: REPL.Config)(implicit ctx: Con /** interpret all lines from a specified file */ def interpretAllFrom(filename: String): Unit = { - val fileIn = try { - new FileReader(filename) - } catch { - case _: IOException => - output.println("Error opening file: " + filename) - return - } - val oldIn = in - val oldReplay = replayCommandsRev + import java.nio.file.{Files, Paths} + import scala.collection.JavaConversions._ try { - val inFile = new BufferedReader(fileIn) - in = new SimpleReader(inFile, output, false) + val lines = Files.readAllLines(Paths.get(filename)).mkString("\n") output.println("Loading " + filename + "...") output.flush - repl() - } finally { - in = oldIn - replayCommandsRev = oldReplay - fileIn.close + interpreter.interpret(lines) + } catch { + case _: IOException => + output.println("Error opening file: " + filename) } } |