Skip to content

Commit a90a784

Browse files
authored
Merge pull request #1585 from dos65/repl_file_loading
Fix #1552: REPL file loading
2 parents 1c62d05 + 7f2b7d4 commit a90a784

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

src/dotty/tools/dotc/repl/InterpreterLoop.scala

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,25 +83,16 @@ class InterpreterLoop(compiler: Compiler, config: REPL.Config)(implicit ctx: Con
8383

8484
/** interpret all lines from a specified file */
8585
def interpretAllFrom(filename: String): Unit = {
86-
val fileIn = try {
87-
new FileReader(filename)
88-
} catch {
89-
case _: IOException =>
90-
output.println("Error opening file: " + filename)
91-
return
92-
}
93-
val oldIn = in
94-
val oldReplay = replayCommandsRev
86+
import java.nio.file.{Files, Paths}
87+
import scala.collection.JavaConversions._
9588
try {
96-
val inFile = new BufferedReader(fileIn)
97-
in = new SimpleReader(inFile, output, false)
89+
val lines = Files.readAllLines(Paths.get(filename)).mkString("\n")
9890
output.println("Loading " + filename + "...")
9991
output.flush
100-
repl()
101-
} finally {
102-
in = oldIn
103-
replayCommandsRev = oldReplay
104-
fileIn.close
92+
interpreter.interpret(lines)
93+
} catch {
94+
case _: IOException =>
95+
output.println("Error opening file: " + filename)
10596
}
10697
}
10798

0 commit comments

Comments
 (0)