aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos65 <qtankle@gmail.com>2016-10-13 02:10:55 +0300
committerdos65 <qtankle@gmail.com>2016-10-13 02:52:28 +0300
commit7f2b7d48f416ecdca97f021e75c0a049374b1daf (patch)
tree0351650609e9fd63d43da868b2d77546ca66c574 /src
parentec28ea175c32ee192a28139ee88f39afbd30d159 (diff)
downloaddotty-7f2b7d48f416ecdca97f021e75c0a049374b1daf.tar.gz
dotty-7f2b7d48f416ecdca97f021e75c0a049374b1daf.tar.bz2
dotty-7f2b7d48f416ecdca97f021e75c0a049374b1daf.zip
Fix #1552: loading file inside REPL
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/repl/InterpreterLoop.scala23
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)
}
}