diff options
author | paltherr <paltherr@epfl.ch> | 2004-04-06 08:52:16 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2004-04-06 08:52:16 +0000 |
commit | 5dc50833450033d06f845bc7473808731a155f82 (patch) | |
tree | 79a532329ec0350504285ecc00decb3b7c16a045 /sources/scalac/transformer/AddConstructors.java | |
parent | 43505887a331fbf647ba39a85bdf16c321ce8037 (diff) | |
download | scala-5dc50833450033d06f845bc7473808731a155f82.tar.gz scala-5dc50833450033d06f845bc7473808731a155f82.tar.bz2 scala-5dc50833450033d06f845bc7473808731a155f82.zip |
- Added Tree.Create
Diffstat (limited to 'sources/scalac/transformer/AddConstructors.java')
-rw-r--r-- | sources/scalac/transformer/AddConstructors.java | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/sources/scalac/transformer/AddConstructors.java b/sources/scalac/transformer/AddConstructors.java index d592f83be7..b8e71d0c3f 100644 --- a/sources/scalac/transformer/AddConstructors.java +++ b/sources/scalac/transformer/AddConstructors.java @@ -221,20 +221,21 @@ public class AddConstructors extends GenTransformer { return gen.New(transform(init, true)); case TypeApply(Tree fun, Tree[] args): - if (!inNew && fun.symbol().isConstructor()) return transform(fun); - return gen.TypeApply(transform(fun, inNew), transform(args)); + if (!fun.symbol().isConstructor()) return super.transform(tree); + if (!inNew) return transform(fun); + assert fun instanceof Tree.Ident: tree; + return transform(tree, fun.symbol(), transform(args)); case Apply(Tree fun, Tree[] args): return gen.Apply(transform(fun, inNew), transform(args)); case Ident(_): Symbol symbol = tree.symbol(); + if (inNew) return transform(tree, symbol, Tree.EMPTY_ARRAY); if (symbol.isConstructor()) { symbol = getInitializer(symbol); - if (!inNew) { - Symbol clasz = symbol.owner(); - return gen.Select(gen.This(tree.pos, clasz), symbol); - } + Symbol clasz = symbol.owner(); + return gen.Select(gen.This(tree.pos, clasz), symbol); } else if (symbol.owner().isConstructor()) { symbol = subst.lookupSymbol(symbol); } @@ -249,4 +250,13 @@ public class AddConstructors extends GenTransformer { } // transform() + /** Transforms the new instance creation. */ + private Tree transform(Tree tree, Symbol constructor, Tree[] targs) { + assert constructor.isConstructor(): tree; + Symbol initializer = getInitializer(constructor); + Symbol clasz = initializer.owner(); + Tree instance = gen.Create(tree.pos, Tree.Empty, clasz, targs); + return gen.Select(tree.pos, instance, initializer); + } + } // class AddConstructors |