Skip to content

Commit a79ce3f

Browse files
committed
Do not fold jlr.Array.newInstance(classOf[Unit], ...).
If we do, we generate code that statically refers to the array type `void[]`, which is not a valid type. With the following commit, the optimizer will have enough knowledge to enter in this case when optimizing `ClassTag`s, resulting in ClassDef checking errors after the optimizer.
1 parent 1aabf39 commit a79ce3f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

linker/shared/src/main/scala/org/scalajs/linker/frontend/optimizer/OptimizerCore.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3195,7 +3195,7 @@ private[optimizer] abstract class OptimizerCore(
31953195
case ArrayNewInstance =>
31963196
val List(tcomponentType, tlength) = targs
31973197
tcomponentType match {
3198-
case PreTransTree(ClassOf(elementTypeRef), _) =>
3198+
case PreTransTree(ClassOf(elementTypeRef), _) if elementTypeRef != VoidRef =>
31993199
val arrayTypeRef = ArrayTypeRef.of(elementTypeRef)
32003200
contTree(NewArray(arrayTypeRef, List(finishTransformExpr(tlength))))
32013201
case _ =>

0 commit comments

Comments
 (0)