aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartijn Hoekstra <Martijn Hoekstra>2016-09-03 12:10:53 +0200
committerMartijn Hoekstra <Martijn Hoekstra>2016-09-07 22:32:51 +0200
commit32819e2edc88dd06095704c04ed9c2dd0603386f (patch)
tree5ac33b7a4fc11fe5b13aeae26e963e5553e97fad /src
parent6bce106fea7ce10eefc864a6e7c1351675065880 (diff)
downloaddotty-32819e2edc88dd06095704c04ed9c2dd0603386f.tar.gz
dotty-32819e2edc88dd06095704c04ed9c2dd0603386f.tar.bz2
dotty-32819e2edc88dd06095704c04ed9c2dd0603386f.zip
honor -encoding compiler flag and defaults
rename test/pos/valueclasses to pos_valueclasses tests/pos/valueclasses generates a valueclasses.flags file in /tests/partest-generated/pos that conflicts with the valueClasses.flags file that tests/neg/valueClasses.scala tries to create
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/Run.scala6
-rw-r--r--src/dotty/tools/dotc/config/Settings.scala2
-rw-r--r--src/dotty/tools/dotc/util/SourceFile.scala7
3 files changed, 10 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala
index 1a26748bf..fa69530b5 100644
--- a/src/dotty/tools/dotc/Run.scala
+++ b/src/dotty/tools/dotc/Run.scala
@@ -9,6 +9,7 @@ import Phases._
import Decorators._
import dotty.tools.dotc.transform.TreeTransforms.TreeTransformer
import io.PlainFile
+import scala.io.Codec
import util._
import reporting.Reporter
import transform.TreeChecker
@@ -28,8 +29,9 @@ class Run(comp: Compiler)(implicit ctx: Context) {
var units: List[CompilationUnit] = _
def getSource(fileName: String): SourceFile = {
+ val encoding = ctx.settings.encoding.value
val f = new PlainFile(fileName)
- if (f.exists) new SourceFile(f)
+ if (f.exists) new SourceFile(f, Codec(encoding))
else {
ctx.error(s"not found: $fileName")
NoSource
@@ -113,7 +115,7 @@ class Run(comp: Compiler)(implicit ctx: Context) {
val writer = new BufferedWriter(new OutputStreamWriter(virtualFile.output, "UTF-8")) // buffering is still advised by javadoc
writer.write(sourceCode)
writer.close()
- compileSources(List(new SourceFile(virtualFile)))
+ compileSources(List(new SourceFile(virtualFile, Codec.UTF8)))
}
/** The context created for this run */
diff --git a/src/dotty/tools/dotc/config/Settings.scala b/src/dotty/tools/dotc/config/Settings.scala
index 73df4e1ec..cffa047fe 100644
--- a/src/dotty/tools/dotc/config/Settings.scala
+++ b/src/dotty/tools/dotc/config/Settings.scala
@@ -25,6 +25,8 @@ object Settings {
private var values = ArrayBuffer(initialValues: _*)
private var _wasRead: Boolean = false
+ override def toString = s"SettingsState(values: ${values.toList})"
+
def value(idx: Int): Any = {
_wasRead = true
values(idx)
diff --git a/src/dotty/tools/dotc/util/SourceFile.scala b/src/dotty/tools/dotc/util/SourceFile.scala
index 6b547203e..344bc253a 100644
--- a/src/dotty/tools/dotc/util/SourceFile.scala
+++ b/src/dotty/tools/dotc/util/SourceFile.scala
@@ -10,6 +10,7 @@ import java.io.IOException
import Chars._
import ScriptSourceFile._
import Positions._
+import scala.io.Codec
import java.util.Optional
@@ -36,9 +37,9 @@ object ScriptSourceFile {
case class SourceFile(file: AbstractFile, content: Array[Char]) extends interfaces.SourceFile {
- def this(_file: AbstractFile) = this(_file, _file.toCharArray)
- def this(sourceName: String, cs: Seq[Char]) = this(new VirtualFile(sourceName), cs.toArray)
- def this(file: AbstractFile, cs: Seq[Char]) = this(file, cs.toArray)
+ def this(_file: AbstractFile, codec: Codec) = this(_file, new String(_file.toByteArray, codec.charSet).toCharArray)
+ def this(sourceName: String, cs: Seq[Char]) = this(new VirtualFile(sourceName), cs.toArray)
+ def this(file: AbstractFile, cs: Seq[Char]) = this(file, cs.toArray)
/** Tab increment; can be overridden */
def tabInc = 8