Skip to content

Commit

Permalink
Address review comments of scala#1188
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkDimius committed Apr 18, 2016
1 parent 0b1ca2d commit 5399fbe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class Compiler {
new Getters, // Replace non-private vals and vars with getter defs (fields are added later)
new ElimByName, // Expand by-name parameters and arguments
new AugmentScala2Traits, // Expand traits defined in Scala 2.11 to simulate old-style rewritings
new ResolveSuper, // Implement super accessors and add forwarders to trait methods
new ArrayConstructors) // Intercept creation of (non-generic) arrays and intrinsify.
new ResolveSuper, // Implement super accessors and add forwarders to trait methods
new ArrayConstructors), // Intercept creation of (non-generic) arrays and intrinsify.
List(new Erasure), // Rewrite types to JVM model, erasing all type parameters, abstract types and refinements.
List(new ElimErasedValueType, // Expand erased value types to their underlying implmementation types
new VCElideAllocations, // Peep-hole optimization to eliminate unnecessary value class allocations
Expand Down
11 changes: 5 additions & 6 deletions src/dotty/tools/dotc/transform/ArrayConstructors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ import ast.Trees._
import dotty.tools.dotc.ast.tpd
import util.Positions._
import Names._

import collection.mutable
import ResolveSuper._

import scala.collection.immutable.::


/** This phase rewrites calls to array constructors to newArray method in Dotty.runtime.Arrays module.
*
Expand All @@ -36,12 +39,8 @@ class ArrayConstructors extends MiniPhaseTransform { thisTransform =>
tpd.newArray(elemType, tree.tpe, tree.pos, JavaSeqLiteral(dims, TypeTree(defn.IntClass.typeRef)))

if (tree.fun.symbol eq defn.ArrayConstructor) {
tree.fun match {
case TypeApply(tycon, targ :: Nil) =>
rewrite(targ.tpe, tree.args)
case _ =>
???
}
val TypeApply(tycon, targ :: Nil) = tree.fun
rewrite(targ.tpe, tree.args)
} else if ((tree.fun.symbol.maybeOwner eq defn.ArrayModule) && (tree.fun.symbol.name eq nme.ofDim) && !tree.tpe.isInstanceOf[MethodicType]) {

tree.fun match {
Expand Down
4 changes: 3 additions & 1 deletion src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,9 @@ trait Applications extends Compatibility { self: Typer =>
fullyDefinedType(tree.tpe, "array", tree.pos)

def newGenericArrayCall =
ref(defn.DottyArraysModule).select(defn.newGenericArrayMethod).withPos(tree.pos).appliedToTypeTrees(targs).appliedToArgs(args)
ref(defn.DottyArraysModule)
.select(defn.newGenericArrayMethod).withPos(tree.pos)
.appliedToTypeTrees(targs).appliedToArgs(args)

if (TypeErasure.isUnboundedGeneric(targ.tpe))
newGenericArrayCall
Expand Down

0 comments on commit 5399fbe

Please sign in to comment.