@@ -556,7 +556,7 @@ trait Applications extends Compatibility { self: Typer =>
556
556
if (proto.argsAreTyped) new ApplyToTyped (tree, fun1, funRef, proto.typedArgs, pt)
557
557
else new ApplyToUntyped (tree, fun1, funRef, proto, pt)(argCtx)
558
558
val result = app.result
559
- ConstFold (result)
559
+ convertNewArray( ConstFold (result) )
560
560
} { (failedVal, failedState) =>
561
561
val fun2 = tryInsertImplicitOnQualifier(fun1, proto)
562
562
if (fun1 eq fun2) {
@@ -632,6 +632,18 @@ trait Applications extends Compatibility { self: Typer =>
632
632
def adaptTypeArg (tree : tpd.Tree , bound : Type )(implicit ctx : Context ): tpd.Tree =
633
633
tree.withType(tree.tpe.etaExpandIfHK(bound))
634
634
635
+ /** Rewrite `new Array[T](....)` trees to calls of newXYZArray methods.
636
+ * It is performed during typer as creation of generic arrays needs a classTag.
637
+ * we rely on implicit search to find one
638
+ */
639
+ def convertNewArray (tree : tpd.Tree )(implicit ctx : Context ): tpd.Tree = tree match {
640
+ case Apply (TypeApply (tycon, targ :: Nil ), args) if tycon.symbol == defn.ArrayConstructor =>
641
+ fullyDefinedType(tree.tpe, " array" , tree.pos)
642
+ newArray(targ.tpe, tree.tpe, tree.pos, JavaSeqLiteral (args, TypeTree (defn.IntClass .typeRef)))
643
+ case _ =>
644
+ tree
645
+ }
646
+
635
647
def typedUnApply (tree : untpd.Apply , selType : Type )(implicit ctx : Context ): Tree = track(" typedUnApply" ) {
636
648
val Apply (qual, args) = tree
637
649
0 commit comments