Skip to content

Commit d97c30a

Browse files
Backport "Fix #22794: Emit the definition of Arrays.newArray even though it's a primitive." to 3.7.0 (#22801)
Backports #22797 to Scala 3.7.0-RC2
2 parents 6967338 + 4e75ac7 commit d97c30a

File tree

5 files changed

+14
-1
lines changed

5 files changed

+14
-1
lines changed

compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ class JSCodeGen()(using genCtx: Context) {
15571557

15581558
def jsParams = params.map(genParamDef(_))
15591559

1560-
if (primitives.isPrimitive(sym)) {
1560+
if (primitives.isPrimitive(sym) && sym != defn.newArrayMethod) {
15611561
None
15621562
} else if (sym.is(Deferred) && currentClassSym.isNonNativeJSClass) {
15631563
// scala-js/#4409: Do not emit abstract methods in non-native JS classes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
enablePlugins(ScalaJSPlugin)
2+
3+
scalaVersion := sys.props("plugin.scalaVersion")
4+
5+
libraryDependencies += "org.scalameta" %%% "munit" % "1.1.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % sys.props("plugin.scalaJSVersion"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class NewArrayIssue22794Test extends munit.FunSuite {
2+
test("foo") {
3+
assert(2 + 2 == 4)
4+
}
5+
}

sbt-test/scalajs/backward-compat/test

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
> test

0 commit comments

Comments
 (0)