Skip to content

Backport "Fix #22794: Emit the definition of Arrays.newArray even though it's a primitive." to 3.3 LTS #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/backend/sjs/JSCodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ class JSCodeGen()(using genCtx: Context) {

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

if (primitives.isPrimitive(sym)) {
if (primitives.isPrimitive(sym) && sym != defn.newArrayMethod) {
None
} else if (sym.is(Deferred) && currentClassSym.isNonNativeJSClass) {
// scala-js/#4409: Do not emit abstract methods in non-native JS classes
Expand Down
5 changes: 5 additions & 0 deletions sbt-test/scalajs/backward-compat/build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enablePlugins(ScalaJSPlugin)

scalaVersion := sys.props("plugin.scalaVersion")

libraryDependencies += "org.scalameta" %%% "munit" % "1.0.0-M10"
2 changes: 2 additions & 0 deletions sbt-test/scalajs/backward-compat/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

addSbtPlugin("org.scala-js" % "sbt-scalajs" % sys.props("plugin.scalaJSVersion"))
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class NewArrayIssue22794Test extends munit.FunSuite {
test("foo") {
assert(2 + 2 == 4)
}
}
1 change: 1 addition & 0 deletions sbt-test/scalajs/backward-compat/test
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
> test
Loading