Commit c612ddb
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]
1 parent 95dcbc6 commit c612ddb
File tree
2 files changed
+15
-1
lines changed- compiler/src/dotty/tools/dotc/transform
- tests/sjs-junit/test/org/scalajs/testsuite/compiler
2 files changed
+15
-1
lines changedLines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
31 | 34 | | |
32 | 35 | | |
33 | 36 | | |
| |||
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
148 | 159 | | |
149 | 160 | | |
150 | 161 | | |
| |||
0 commit comments