Skip to content

Backport "Fix #22226: Use classOf[BoxedUnit] for Unit array in ArrayConstructors." to 3.3 LTS #155

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
Mar 14, 2025

Conversation

tgodzik
Copy link

@tgodzik tgodzik commented Mar 13, 2025

Backports scala#22238 to the 3.3.6.

PR submitted by the release tooling.
[skip ci]

…structors`.

The `ArrayConstructors` phase rewrites array constructors to calls
to `scala.runtime.Arrays.newArray`. When it does that, it must pass
the run-time `jl.Class` of the element type. Previously, it used
`classOf[Unit]` when creating an `Array[Unit]` (or nested). That
is not correct, as from the Java perspective, we need to create
`Array[BoxedUnit]`.

We now identify `elemType <: Unit` and replace it with `BoxedUnit`.

---

This highlights a limitation of the Scala.js backend. We should
rewrite calls to `newArray` in the backend to use direct array
creation instead.

[Cherry-picked 442e6a0]
Base automatically changed from backport-lts-3.3-22236 to lts-3.3 March 14, 2025 08:43
@tgodzik
Copy link
Author

tgodzik commented Mar 14, 2025

No regressions detected in the community build up to backport-lts-3.3-22256.

Reference

@tgodzik tgodzik merged commit 915816a into lts-3.3 Mar 14, 2025
22 checks passed
@tgodzik tgodzik deleted the backport-lts-3.3-22238 branch March 14, 2025 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants