-
Notifications
You must be signed in to change notification settings - Fork 396
Closed
Labels
bugConfirmed bug. Needs to be fixed.Confirmed bug. Needs to be fixed.
Milestone
Description
Using Scala.js version 1.1.0
on code that compiles on JVM and Scala Native does not compile.
The code in question starts with (ch: @switch)
. Adding a result val b = (ch: @switch)
allows the code to compile. Removing the @switch
annotation has no effect.
The code can be run via testSuiteJS/test
from this repo: https://github.com/ekrich/portable-scala-java-test
private def encodeString(string: String,
isKey: Boolean,
toHex: Boolean): String = {
val buffer = new jl.StringBuilder(200)
var index = 0
val length = string.length
// leading element (value) spaces are escaped
while (!isKey && index < length && string.charAt(index) == ' ') {
buffer.append("\\ ")
index += 1
}
while (index < length) {
val ch = string.charAt(index)
(ch: @switch) match {
case '\t' =>
buffer.append("\\t")
case '\n' =>
buffer.append("\\n")
case '\f' =>
buffer.append("\\f")
case '\r' =>
buffer.append("\\r")
case '\\' | '#' | '!' | '=' | ':' =>
buffer.append('\\')
buffer.append(ch)
case ' ' if isKey =>
buffer.append("\\ ")
case _ =>
if (toHex && (ch < ' ' || ch > '~')) {
buffer.append(unicodeToHexaDecimal(ch))
} else {
buffer.append(ch)
}
}
index += 1
}
buffer.toString()
}
Error:
sbt:portable-scala-java-test> testSuiteJS/test
[info] Compiling 1 Scala source to /Users/eric/workspace/portable-scala-java-test/scalacode/js/target/scala-2.12/classes ...
[info] Compiling 2 Scala sources to /Users/eric/workspace/portable-scala-java-test/testSuite/js/target/scala-2.12/test-classes ...
[info] Fast optimizing /Users/eric/workspace/portable-scala-java-test/testSuite/js/target/scala-2.12/testsuite-on-js-test-fastopt.js
[error] file:/Users/eric/workspace/portable-scala-java-test/scalacode/shared/src/main/scala/java/util/Properties.scala(332:24:Return): java.lang.StringBuilder expected but void found for tree of type org.scalajs.ir.Trees$Undefined
[error] file:/Users/eric/workspace/portable-scala-java-test/scalacode/shared/src/main/scala/java/util/Properties.scala(334:24:Return): java.lang.StringBuilder expected but void found for tree of type org.scalajs.ir.Trees$Undefined
[error] file:/Users/eric/workspace/portable-scala-java-test/scalacode/shared/src/main/scala/java/util/Properties.scala(336:24:Return): java.lang.StringBuilder expected but void found for tree of type org.scalajs.ir.Trees$Undefined
[error] file:/Users/eric/workspace/portable-scala-java-test/scalacode/shared/src/main/scala/java/util/Properties.scala(338:24:Return): java.lang.StringBuilder expected but void found for tree of type org.scalajs.ir.Trees$Undefined
[error] file:/Users/eric/workspace/portable-scala-java-test/scalacode/shared/src/main/scala/java/util/Properties.scala(339:43:Return): java.lang.StringBuilder expected but void found for tree of type org.scalajs.ir.Trees$Undefined
[error] file:/Users/eric/workspace/portable-scala-java-test/scalacode/shared/src/main/scala/java/util/Properties.scala(330:7:Return): java.lang.StringBuilder expected but void found for tree of type org.scalajs.ir.Trees$Undefined
[error] There were 6 IR checking errors.
[error] (testSuiteJS / Test / fastOptJS) There were 6 IR checking errors.
[error] Total time: 4 s, completed Jun 29, 2020 12:30:54 PM
Metadata
Metadata
Assignees
Labels
bugConfirmed bug. Needs to be fixed.Confirmed bug. Needs to be fixed.