Skip to content

Commit d11e137

Browse files
authored
Merge pull request #9666 from dotty-staging/fix-4588
Enable Windows CI
2 parents 8c94870 + ffe8bf7 commit d11e137

File tree

34 files changed

+153
-114
lines changed

34 files changed

+153
-114
lines changed

.appveyor.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ build_script:
1515
- cmd: sbt dotty-bootstrapped/compile
1616
test_script:
1717
- cmd: sbt "dotty-bootstrapped/dotc tests\pos\HelloWorld.scala"
18+
# - cmd: sbt test
19+
# - cmd: sbt dotty-bootstrapped/test
1820
- cmd: sbt sjsJUnitTests/test

compiler/src/dotty/tools/dotc/Run.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ import Denotations.Denotation
1212
import typer.Typer
1313
import typer.ImportInfo._
1414
import Decorators._
15-
import io.{AbstractFile, PlainFile}
15+
import io.{AbstractFile, PlainFile, VirtualFile}
1616
import Phases.unfusedPhases
1717

18-
import scala.io.Codec
1918
import util._
2019
import reporting.Reporter
2120
import rewrites.Rewrites
22-
import java.io.{BufferedWriter, OutputStreamWriter}
2321

2422
import profile.Profiler
2523
import printing.XprintMode
2624
import parsing.Parsers.Parser
2725
import parsing.JavaParsers.JavaParser
2826
import typer.ImplicitRunInfo
29-
import collection.mutable
3027

31-
import dotty.tools.io.VirtualFile
28+
import java.io.{BufferedWriter, OutputStreamWriter}
29+
import java.nio.charset.StandardCharsets
3230

31+
import scala.collection.mutable
3332
import scala.util.control.NonFatal
33+
import scala.io.Codec
3434

3535
/** A compiler run. Exports various methods to compile source files */
3636
class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with ConstraintRunInfo {
@@ -274,7 +274,7 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint
274274
val uuid = java.util.UUID.randomUUID().toString
275275
val ext = if (isJava) ".java" else ".scala"
276276
val virtualFile = new VirtualFile(s"compileFromString-$uuid.$ext")
277-
val writer = new BufferedWriter(new OutputStreamWriter(virtualFile.output, "UTF-8")) // buffering is still advised by javadoc
277+
val writer = new BufferedWriter(new OutputStreamWriter(virtualFile.output, StandardCharsets.UTF_8.name)) // buffering is still advised by javadoc
278278
writer.write(source)
279279
writer.close()
280280
new SourceFile(virtualFile, Codec.UTF8)

compiler/src/dotty/tools/dotc/config/Properties.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import scala.annotation.internal.sharable
66

77
import java.io.IOException
88
import java.util.jar.Attributes.{ Name => AttributeName }
9+
import java.nio.charset.StandardCharsets
910

1011
/** Loads `library.properties` from the jar. */
1112
object Properties extends PropertiesTrait {
@@ -88,13 +89,13 @@ trait PropertiesTrait {
8889
/** This is the encoding to use reading in source files, overridden with -encoding
8990
* Note that it uses "prop" i.e. looks in the scala jar, not the system properties.
9091
*/
91-
def sourceEncoding: String = scalaPropOrElse("file.encoding", "UTF-8")
92+
def sourceEncoding: String = scalaPropOrElse("file.encoding", StandardCharsets.UTF_8.name)
9293
def sourceReader: String = scalaPropOrElse("source.reader", "scala.tools.nsc.io.SourceReader")
9394

9495
/** This is the default text encoding, overridden (unreliably) with
9596
* `JAVA_OPTS="-Dfile.encoding=Foo"`
9697
*/
97-
def encodingString: String = propOrElse("file.encoding", "UTF-8")
98+
def encodingString: String = propOrElse("file.encoding", StandardCharsets.UTF_8.name)
9899

99100
/** The default end of line character.
100101
*/

compiler/src/dotty/tools/dotc/core/tasty/CommentPickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import dotty.tools.dotc.core.Contexts._
77
import dotty.tools.tasty.TastyBuffer
88
import TastyBuffer.{Addr, NoAddr}
99

10-
import java.nio.charset.Charset
10+
import java.nio.charset.StandardCharsets
1111

1212
class CommentPickler(pickler: TastyPickler, addrOfTree: tpd.Tree => Addr, docString: untpd.MemberDef => Option[Comment]):
1313
private val buf = new TastyBuffer(5000)
@@ -17,7 +17,7 @@ class CommentPickler(pickler: TastyPickler, addrOfTree: tpd.Tree => Addr, docStr
1717

1818
private def pickleComment(addr: Addr, comment: Comment): Unit =
1919
if addr != NoAddr then
20-
val bytes = comment.raw.getBytes(Charset.forName("UTF-8"))
20+
val bytes = comment.raw.getBytes(StandardCharsets.UTF_8)
2121
val length = bytes.length
2222
buf.writeAddr(addr)
2323
buf.writeNat(length)

compiler/src/dotty/tools/dotc/core/tasty/CommentUnpickler.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import util.HashMap
88
import dotty.tools.tasty.{TastyReader, TastyBuffer}
99
import TastyBuffer.Addr
1010

11-
import java.nio.charset.Charset
11+
import java.nio.charset.StandardCharsets
1212

1313
class CommentUnpickler(reader: TastyReader) {
1414
import reader._
@@ -21,7 +21,7 @@ class CommentUnpickler(reader: TastyReader) {
2121
if (length > 0) {
2222
val bytes = readBytes(length)
2323
val position = new Span(readLongInt())
24-
val rawComment = new String(bytes, Charset.forName("UTF-8"))
24+
val rawComment = new String(bytes, StandardCharsets.UTF_8)
2525
comments(addr) = Comment(position, rawComment)
2626
}
2727
}

compiler/src/dotty/tools/dotc/decompiler/DecompilationPrinter.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dotty.tools.dotc
22
package decompiler
33

44
import java.io.{OutputStream, PrintStream}
5+
import java.nio.charset.StandardCharsets
56

67
import scala.io.Codec
78

@@ -27,7 +28,7 @@ class DecompilationPrinter extends Phase {
2728
var ps: PrintStream = null
2829
try {
2930
os = File(outputDir.fileNamed("decompiled.scala").path)(Codec.UTF8).outputStream(append = true)
30-
ps = new PrintStream(os, /* autoFlush = */ false, "UTF-8")
31+
ps = new PrintStream(os, /* autoFlush = */ false, StandardCharsets.UTF_8.name)
3132
printToOutput(ps)
3233
}
3334
finally {

compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import java.net.URI
66
import java.io._
77
import java.nio.file._
88
import java.nio.file.attribute.BasicFileAttributes
9+
import java.nio.charset.StandardCharsets
910
import java.util.zip._
1011

1112
import scala.collection._
@@ -298,7 +299,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
298299
private def toSource(uri: URI, sourceCode: String): SourceFile = {
299300
val path = Paths.get(uri)
300301
val virtualFile = new VirtualFile(path.getFileName.toString, path.toString)
301-
val writer = new BufferedWriter(new OutputStreamWriter(virtualFile.output, "UTF-8"))
302+
val writer = new BufferedWriter(new OutputStreamWriter(virtualFile.output, StandardCharsets.UTF_8.name))
302303
writer.write(sourceCode)
303304
writer.close()
304305
new SourceFile(virtualFile, Codec.UTF8)

compiler/src/dotty/tools/dotc/semanticdb/internal/SemanticdbInputStream.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package dotty.tools.dotc.semanticdb.internal
33
import java.io.IOException
44
import java.io.InputStream
55
import java.util.Arrays
6+
import java.nio.charset.StandardCharsets
7+
68
import SemanticdbInputStream._
79

810
import scala.collection.mutable
@@ -434,15 +436,15 @@ class SemanticdbInputStream private (buffer: Array[Byte], input: InputStream) {
434436
def readString(): String = {
435437
val size: Int = readRawVarint32()
436438
if (size <= (bufferSize - bufferPos) && size > 0) {
437-
val result: String = new String(buffer, bufferPos, size, Internal.UTF_8)
439+
val result: String = new String(buffer, bufferPos, size, StandardCharsets.UTF_8)
438440
bufferPos += size
439441
return result
440442
}
441443
else if (size == 0) {
442444
return ""
443445
}
444446
else {
445-
return new String(readRawBytesSlowPath(size), Internal.UTF_8)
447+
return new String(readRawBytesSlowPath(size), StandardCharsets.UTF_8)
446448
}
447449
}
448450

compiler/src/dotty/tools/dotc/semanticdb/internal/SemanticdbOutputStream.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package dotty.tools.dotc.semanticdb.internal
33
import java.io.IOException
44
import java.io.OutputStream
55
import java.nio.ByteBuffer
6+
import java.nio.charset.StandardCharsets
7+
68
import SemanticdbOutputStream._
79

810
object SemanticdbOutputStream {
@@ -144,7 +146,7 @@ object SemanticdbOutputStream {
144146
def computeBoolSizeNoTag(value: Boolean): Int = 1
145147

146148
def computeStringSizeNoTag(value: String): Int = {
147-
val bytes = value.getBytes(Internal.UTF_8)
149+
val bytes = value.getBytes(StandardCharsets.UTF_8)
148150
computeRawVarint32Size(bytes.length) + bytes.length
149151
}
150152

@@ -391,7 +393,7 @@ class SemanticdbOutputStream(output: OutputStream, buffer: Array[Byte]) {
391393
}
392394

393395
def writeStringNoTag(value: String): Unit = {
394-
val bytes = value.getBytes(Internal.UTF_8)
396+
val bytes = value.getBytes(StandardCharsets.UTF_8)
395397
writeRawVarint32(bytes.length)
396398
writeRawBytes(bytes)
397399
}
@@ -602,6 +604,5 @@ class SemanticdbOutputStream(output: OutputStream, buffer: Array[Byte]) {
602604
}
603605

604606
object Internal {
605-
val UTF_8 = java.nio.charset.Charset.forName("UTF-8")
606607
val EMPTY_BYTE_ARRAY: Array[Byte] = Array()
607608
}

compiler/src/dotty/tools/dotc/util/ShowPickled.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ package dotty.tools.dotc
22
package util
33

44
import java.io.PrintStream
5+
import java.nio.charset.StandardCharsets
56
import java.lang.Long.toHexString
67
import java.lang.Float.intBitsToFloat
78
import java.lang.Double.longBitsToDouble
9+
810
import core.unpickleScala2.PickleBuffer
911
import core.Names._
1012

@@ -18,7 +20,7 @@ object ShowPickled {
1820
case _ => false
1921
}
2022
def readName: String =
21-
if (isName) new String(bytes, "UTF-8")
23+
if (isName) new String(bytes, StandardCharsets.UTF_8)
2224
else sys.error("%s is no name" format tagName)
2325
def nameIndex: Int =
2426
if (hasName) readNat(bytes, 0)

0 commit comments

Comments
 (0)