aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/Run.scala16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala
index cc9b8db3a..df7f433f9 100644
--- a/src/dotty/tools/dotc/Run.scala
+++ b/src/dotty/tools/dotc/Run.scala
@@ -6,7 +6,8 @@ import Contexts._, Periods._, Symbols._
import io.PlainFile
import util.{SourceFile, NoSource, Stats, SimpleMap}
import reporting.Reporter
-import java.io.FileWriter
+import java.io.{BufferedWriter, OutputStreamWriter}
+import scala.reflect.io.VirtualFile
class Run(comp: Compiler)(implicit ctx: Context) {
@@ -21,8 +22,12 @@ class Run(comp: Compiler)(implicit ctx: Context) {
}
}
- def compile(fileNames: List[String]): Unit = Stats.monitorHeartBeat {
+ def compile(fileNames: List[String]): Unit = {
val sources = fileNames map getSource
+ compileSources(sources)
+ }
+
+ def compileSources(sources: List[SourceFile]) = Stats.monitorHeartBeat {
if (sources forall (_.exists)) {
units = sources map (new CompilationUnit(_))
for (phase <- ctx.allPhases)
@@ -31,12 +36,11 @@ class Run(comp: Compiler)(implicit ctx: Context) {
}
def compile(sourceCode: String): Unit = {
- val tmpFile = java.io.File.createTempFile("dotty-source-tmp", ".scala")
- tmpFile.createNewFile()
- val writer = new FileWriter(tmpFile)
+ val virtualFile = new VirtualFile(sourceCode) // use source code as name as it's used for equals
+ val writer = new BufferedWriter(new OutputStreamWriter(virtualFile.output, "UTF-8")) // buffering is still advised by javadoc
writer.write(sourceCode)
writer.close()
- compile(List(tmpFile.getAbsolutePath))
+ compileSources(List(new SourceFile(virtualFile)))
}
/** Print summary; return # of errors encountered */