From 91c61e4694097971b9a0c139048b7239d0f05588 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 28 Nov 2014 22:10:37 +0100 Subject: Previous scheme was buggy; leaked Array types to backend. Now: All new Array[T] methods are translated to calls of the form dotty.Arrays.newXYZArray ... --- src/dotty/tools/dotc/typer/Applications.scala | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/typer/Applications.scala') diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index ba770cf2c..fe45beb04 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -596,7 +596,16 @@ trait Applications extends Compatibility { self: Typer => checkBounds(typedArgs, pt) case _ => } - assignType(cpy.TypeApply(tree)(typedFn, typedArgs), typedFn, typedArgs) + convertNewArray( + 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) + case _ => + tree } def typedUnApply(tree: untpd.Apply, selType: Type)(implicit ctx: Context): Tree = track("typedUnApply") { -- cgit v1.2.3