aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala14
-rw-r--r--tests/pos/new-array.scala3
2 files changed, 9 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index 47dfe157d..582642325 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -530,7 +530,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)
val result = app.result
- ConstFold(result)
+ convertNewArray(ConstFold(result))
} { (failedVal, failedState) =>
val fun2 = tryInsertImplicitOnQualifier(fun1, proto)
if (fun1 eq fun2) {
@@ -596,14 +596,14 @@ trait Applications extends Compatibility { self: Typer =>
checkBounds(typedArgs, pt)
case _ =>
}
- convertNewArray(
- assignType(cpy.TypeApply(tree)(typedFn, typedArgs), typedFn, typedArgs))
+ assignType(cpy.TypeApply(tree)(typedFn, typedArgs), typedFn, typedArgs)
}
- /** Rewrite `new Array[T]` trees to calls of newXYZArray methods. */
- def convertNewArray(tree: Tree)(implicit ctx: Context): Tree = tree match {
- case TypeApply(tycon, targs) if tycon.symbol == defn.ArrayConstructor =>
- newArray(targs.head, tree.pos)
+ /** Rewrite `new Array[T](....)` trees to calls of newXYZArray methods. */
+ 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)
+ tpd.cpy.Apply(tree)(newArray(targ, tree.pos), args)
case _ =>
tree
}
diff --git a/tests/pos/new-array.scala b/tests/pos/new-array.scala
index 9deb2330a..98b8345a0 100644
--- a/tests/pos/new-array.scala
+++ b/tests/pos/new-array.scala
@@ -6,9 +6,10 @@ object Test {
val z = new Array[Unit](10)
}
object Test2 {
- val w: Array[String] = new Array(10)
+ val w: Array[Any] = new Array(10)
val x: Array[Int] = new Array(10)
def f[T: reflect.ClassTag]: Array[T] = new Array(10)
val y: Array[Any] = new Array(10)
val z: Array[Unit] = new Array(10)
}
+