Skip to content

Commit 769f8a0

Browse files
committed
arrayConstructors: do not rewrite ofDim for arrays of value classes
1 parent 0514d0e commit 769f8a0

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/dotty/tools/dotc/transform/ArrayConstructors.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,18 @@ class ArrayConstructors extends MiniPhaseTransform { thisTransform =>
4242
val TypeApply(tycon, targ :: Nil) = tree.fun
4343
rewrite(targ.tpe, tree.args)
4444
} else if ((tree.fun.symbol.maybeOwner eq defn.ArrayModule) && (tree.fun.symbol.name eq nme.ofDim) && !tree.tpe.isInstanceOf[MethodicType]) {
45-
45+
val Apply(Apply(TypeApply(_, List(tp)), _), _) = tree
46+
val cs = tp.tpe.widen.classSymbol
4647
tree.fun match {
47-
case Apply(TypeApply(t: Ident, targ), dims) if !TypeErasure.isUnboundedGeneric(targ.head.tpe) =>
48+
case Apply(TypeApply(t: Ident, targ), dims)
49+
if !TypeErasure.isUnboundedGeneric(targ.head.tpe) && !ValueClasses.isDerivedValueClass(cs) =>
4850
rewrite(targ.head.tpe, dims)
49-
case Apply(TypeApply(t: Select, targ), dims) if !TypeErasure.isUnboundedGeneric(targ.head.tpe) =>
51+
case Apply(TypeApply(t: Select, targ), dims)
52+
if !TypeErasure.isUnboundedGeneric(targ.head.tpe) && !ValueClasses.isDerivedValueClass(cs) =>
5053
Block(t.qualifier :: Nil, rewrite(targ.head.tpe, dims))
5154
case _ => tree
5255
}
5356

5457
} else tree
5558
}
5659
}
57-

0 commit comments

Comments
 (0)