From 7f2b7d48f416ecdca97f021e75c0a049374b1daf Mon Sep 17 00:00:00 2001 From: dos65 Date: Thu, 13 Oct 2016 02:10:55 +0300 Subject: Fix #1552: loading file inside REPL --- src/dotty/tools/dotc/repl/InterpreterLoop.scala | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'src') 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) } } -- cgit v1.2.3