diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-06 14:12:14 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-06 14:12:14 +0100 |
commit | 3e313ac00f51d7d733955d613c554a8807fa7ec2 (patch) | |
tree | f986722161ede81d6fa3fd541779ada18c0daf83 /src | |
parent | 78b57e3c5a2ca0c15729e6f6a3e43c718028754e (diff) | |
download | dotty-3e313ac00f51d7d733955d613c554a8807fa7ec2.tar.gz dotty-3e313ac00f51d7d733955d613c554a8807fa7ec2.tar.bz2 dotty-3e313ac00f51d7d733955d613c554a8807fa7ec2.zip |
Made New(tpt, args) work for parameterized types tpt.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/ast/untpd.scala | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/ast/untpd.scala b/src/dotty/tools/dotc/ast/untpd.scala index ab9de706d..351548d91 100644 --- a/src/dotty/tools/dotc/ast/untpd.scala +++ b/src/dotty/tools/dotc/ast/untpd.scala @@ -96,10 +96,19 @@ object untpd extends Trees.Instance[Untyped] with TreeInfo[Untyped] { // def TypeTree(tpe: Type): TypeTree = TypeTree().withType(tpe) todo: move to untpd/tpd - /** new tpt(args1)...(args_n) + /** new pre.C[Ts](args1)...(args_n) + * ==> + * (new pre.C).<init>[Ts](args1)...(args_n) */ - def New(tpt: Tree, argss: List[List[Tree]]): Tree = - ((Select(New(tpt), nme.CONSTRUCTOR): Tree) /: argss)(Apply(_, _)) + def New(tpt: Tree, argss: List[List[Tree]]): Tree = { + val (tycon, targs) = tpt match { + case AppliedTypeTree(tycon, targs) => (tycon, targs) + case _ => (tpt, Nil) + } + var prefix: Tree = Select(New(tycon), nme.CONSTRUCTOR) + if (targs.nonEmpty) prefix = TypeApply(prefix, targs) + (prefix /: argss)(Apply(_, _)) + } def Block(stat: Tree, expr: Tree): Block = Block(stat :: Nil, expr) |