Skip to content

Commit 5e9891e

Browse files
committed
In Scala.js mode, compile all lazy vals as thread-unsafe.
Since JS is a single-threaded environment, there is no point going through all the machinery of thread-safe lazy vals. This fixes lazy vals for JS, which would previously fail to link because of the dependency on `Unsafe`, which is not supported in Scala.js.
1 parent f0fd5de commit 5e9891e

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

compiler/src/dotty/tools/dotc/transform/LazyVals.scala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ class LazyVals extends MiniPhase with IdentityDenotTransformer {
7676
if (isField) {
7777
if (sym.isAllOf(SyntheticModule))
7878
transformSyntheticModule(tree)
79-
else if (sym.isThreadUnsafe) {
80-
if (sym.is(Module)) {
79+
else if (sym.isThreadUnsafe || ctx.settings.scalajs.value) {
80+
if (sym.is(Module) && !ctx.settings.scalajs.value) {
8181
ctx.error(em"@threadUnsafe is only supported on lazy vals", sym.sourcePos)
8282
transformMemberDefThreadSafe(tree)
8383
}
@@ -453,6 +453,3 @@ object LazyVals {
453453
val retry: TermName = "retry".toTermName
454454
}
455455
}
456-
457-
458-

project/Build.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ object Build {
937937
val dir = fetchScalaJSSource.value / "test-suite"
938938
(
939939
(dir / "shared/src/test/scala/org/scalajs/testsuite/compiler" ** "IntTest.scala").get
940+
++ (dir / "shared/src/test/require-jdk8/org/scalajs/testsuite/javalib/util" ** "Base64Test.scala").get
940941
++ (dir / "shared/src/test/scala/org/scalajs/testsuite/utils" ** "*.scala").get
941942
)
942943
}

0 commit comments

Comments
 (0)