diff options
author | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-03-30 18:20:29 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2016-04-18 14:46:57 +0200 |
commit | 55e2ae676e32eb21c9e0c2eabc2867704c93d34c (patch) | |
tree | 172a285fcb48d27312afe678bd098693cec85609 | |
parent | c74bb42251eb233c858810d83300ba78876a2b2c (diff) | |
download | dotty-55e2ae676e32eb21c9e0c2eabc2867704c93d34c.tar.gz dotty-55e2ae676e32eb21c9e0c2eabc2867704c93d34c.tar.bz2 dotty-55e2ae676e32eb21c9e0c2eabc2867704c93d34c.zip |
ArrayConstructors: don't optimise creating of multi-dim generic arrays.
They need to be created through their class tag.
-rw-r--r-- | src/dotty/tools/dotc/transform/ArrayConstructors.scala | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/transform/ArrayConstructors.scala b/src/dotty/tools/dotc/transform/ArrayConstructors.scala index fbb5bb9d7..fe79627ea 100644 --- a/src/dotty/tools/dotc/transform/ArrayConstructors.scala +++ b/src/dotty/tools/dotc/transform/ArrayConstructors.scala @@ -21,12 +21,11 @@ import collection.mutable import ResolveSuper._ -/** This phase rewrites calls to array constructors to newArray and newGenericArray methods - * in Dotty.runtime.Arrays module. - * - * Additionally it optimizes calls to scala.Array.ofDim functions - * - */ +/** This phase rewrites calls to array constructors to newArray method in Dotty.runtime.Arrays module. + * + * It assummes that generic arrays have already been handled by typer(see Applications.convertNewGenericArray). + * Additionally it optimizes calls to scala.Array.ofDim functions by replacing them with calls to newArray with specific dimensions + */ class ArrayConstructors extends MiniPhaseTransform { thisTransform => import ast.tpd._ @@ -46,9 +45,9 @@ class ArrayConstructors extends MiniPhaseTransform { thisTransform => } else if ((tree.fun.symbol.maybeOwner eq defn.ArrayModule) && (tree.fun.symbol.name eq nme.ofDim) && !tree.tpe.isInstanceOf[MethodicType]) { tree.fun match { - case Apply(TypeApply(t: Ident, targ), dims) => + case Apply(TypeApply(t: Ident, targ), dims) if !TypeErasure.isUnboundedGeneric(targ.head.tpe) => rewrite(targ.head.tpe, dims) - case Apply(TypeApply(t: Select, targ), dims) => + case Apply(TypeApply(t: Select, targ), dims) if !TypeErasure.isUnboundedGeneric(targ.head.tpe) => Block(t.qualifier :: Nil, rewrite(targ.head.tpe, dims)) case _ => tree } |