aboutsummaryrefslogtreecommitdiff
path: root/src/dotty
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2016-03-30 17:12:16 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2016-04-18 14:46:57 +0200
commit9d7db0c2fff12420f7ef37119746860622e40387 (patch)
treed7eb8ee1ce2a26e7383992d9418d72cef9c98719 /src/dotty
parent2c370bdec8d2a8a2c4b339d4e7f18e6215b03244 (diff)
downloaddotty-9d7db0c2fff12420f7ef37119746860622e40387.tar.gz
dotty-9d7db0c2fff12420f7ef37119746860622e40387.tar.bz2
dotty-9d7db0c2fff12420f7ef37119746860622e40387.zip
Bring back convertNewArray into typer.
It's needed in order to create calls to newGenricArray as it needs to infer the ClassTag.
Diffstat (limited to 'src/dotty')
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala14
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala3
2 files changed, 15 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index c0664e0d6..7fb71b7fb 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -560,7 +560,7 @@ trait Applications extends Compatibility { self: Typer =>
if (proto.argsAreTyped) new ApplyToTyped(tree, fun1, funRef, proto.typedArgs, pt)
else new ApplyToUntyped(tree, fun1, funRef, proto, pt)(argCtx(tree))
val result = app.result
- ConstFold(result)
+ convertNewArray(ConstFold(result))
} { (failedVal, failedState) =>
val fun2 = tryInsertImplicitOnQualifier(fun1, proto)
if (fun1 eq fun2) {
@@ -636,6 +636,18 @@ trait Applications extends Compatibility { self: Typer =>
def adaptTypeArg(tree: tpd.Tree, bound: Type)(implicit ctx: Context): tpd.Tree =
tree.withType(tree.tpe.etaExpandIfHK(bound))
+ /** Rewrite `new Array[T](....)` trees to calls of newXYZArray methods.
+ * It is performed during typer as creation of generic arrays needs a classTag.
+ * we rely on implicit search to find one
+ */
+ def convertNewArray(tree: tpd.Tree)(implicit ctx: Context): tpd.Tree = tree match {
+ case Apply(TypeApply(tycon, targ :: Nil), args) if tycon.symbol == defn.ArrayConstructor =>
+ fullyDefinedType(tree.tpe, "array", tree.pos)
+ newArray(targ.tpe, tree.tpe, tree.pos, JavaSeqLiteral(args, TypeTree(defn.IntClass.typeRef)))
+ case _ =>
+ tree
+ }
+
def typedUnApply(tree: untpd.Apply, selType: Type)(implicit ctx: Context): Tree = track("typedUnApply") {
val Apply(qual, args) = tree
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 6a8e93f86..2575dbec2 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -1684,7 +1684,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
case _ => Nil
}
if (typeArgs.isEmpty) typeArgs = constrained(poly, tree)._2
- adaptInterpolated(tree.appliedToTypes(typeArgs), pt, original)
+ convertNewArray(
+ adaptInterpolated(tree.appliedToTypes(typeArgs), pt, original))
}
case wtp =>
pt match {