Skip to content

Commit 8d043f4

Browse files
committed
Don't generate JavaArrayTypes in class constants
E.g. generate Array[Int] instead of []Int. Fixes #11353
1 parent a63b1d1 commit 8d043f4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

compiler/src/dotty/tools/dotc/typer/Synthesizer.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
3939
if defn.SpecialClassTagClasses.contains(sym) then
4040
classTag.select(sym.name.toTermName)
4141
else
42-
classTag.select(nme.apply).appliedToType(tp).appliedTo(clsOf(erasure(tp)))
42+
val clsOfType = erasure(tp) match
43+
case JavaArrayType(elemType) => defn.ArrayOf(elemType)
44+
case etp => etp
45+
classTag.select(nme.apply).appliedToType(tp).appliedTo(clsOf(clsOfType))
4346
tag.withSpan(span)
4447
case tp => EmptyTree
4548
case _ => EmptyTree

tests/pos/i11353.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
def iarr = IArray(
2+
IArray(1, 2, 3),
3+
IArray(4, 5, 6),
4+
IArray(7, 8, 9)
5+
)
6+
def arr = Array( // same issue
7+
IArray(1, 2, 3),
8+
Array(4, 5, 6),
9+
Array(7, 8, 9)
10+
)

0 commit comments

Comments
 (0)