diff options
author | paltherr <paltherr@epfl.ch> | 2003-10-15 09:19:40 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2003-10-15 09:19:40 +0000 |
commit | e9b5eabdb50aa5a8f5ac32a2522eed1347bd21f2 (patch) | |
tree | 9040921a6578b066b3ba9d2b145021ef6348a16b /sources/scalac/ast | |
parent | 96eb45c701a72ef682e297d45a210ca1138ebfa1 (diff) | |
download | scala-e9b5eabdb50aa5a8f5ac32a2522eed1347bd21f2.tar.gz scala-e9b5eabdb50aa5a8f5ac32a2522eed1347bd21f2.tar.bz2 scala-e9b5eabdb50aa5a8f5ac32a2522eed1347bd21f2.zip |
- Renamed mkInterfaceDef into ClassDef
- Changed New to also work with initializers
Diffstat (limited to 'sources/scalac/ast')
-rw-r--r-- | sources/scalac/ast/TreeGen.java | 39 |
1 files changed, 28 insertions, 11 deletions
diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java index ccd3434bf7..d52a2c2fa4 100644 --- a/sources/scalac/ast/TreeGen.java +++ b/sources/scalac/ast/TreeGen.java @@ -665,6 +665,20 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { Template templ = Template(pos, Symbol.NONE, constrs, Tree.EMPTY_ARRAY); New tree = make.New(pos, templ); tree.setType(constr.type); + // after AddConstructor use type of symbol + switch (constr) { + case Apply(TypeApply(Tree fun, Tree[] targs), _): + Symbol sym = fun.symbol(); + if (sym == null || sym.isConstructor()) break; + Type[] args = Tree.typeOf(targs); + tree.setType(Type.appliedType(sym.owner().typeConstructor(),args)); + break; + case Apply(Tree fun, _): + Symbol sym = fun.symbol(); + if (sym == null || sym.isConstructor()) break; + tree.setType(sym.owner().typeConstructor()); + break; + } return tree; } public Tree New(Tree constr) { @@ -731,17 +745,6 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { return ValDef(sym, Tree.Empty); } - /** Builds a definition for given interface with given body. */ - public Tree mkInterfaceDef(Symbol clazz, Tree[] body) { - Global.instance.nextPhase(); - clazz.info(); // needed until isInterface() triggers flag updates - assert clazz.isInterface(): Debug.show(clazz); - Type[] parents = clazz.parents(); - Global.instance.prevPhase(); - Tree[] constrs = mkPrimaryConstrs(clazz.pos, parents); - return ClassDef(clazz, constrs, Symbol.NONE, body); - } - /** Builds a ClassDef node for given class with given template. */ public ClassDef ClassDef(Symbol clazz, Template template) { ClassDef tree = make.ClassDef( @@ -765,6 +768,20 @@ public class TreeGen implements Kinds, Modifiers, TypeTags { return ClassDef(clazz, Template(clazz.pos, local, constrs, body)); } + /** Builds a ClassDef node for given class with given body. */ + public Tree ClassDef(Symbol clazz, Tree[] body) { + for (int i = 0; i < body.length; i++) { + assert body[i].definesSymbol() && body[i].symbol().owner() ==clazz: + "\nclass : " + clazz + + "\nmember: " + body[i]; + } + Global.instance.nextPhase(); + Type[] parents = clazz.parents(); + Global.instance.prevPhase(); + Tree[] constrs = mkPrimaryConstrs(clazz.pos, parents); + return ClassDef(clazz, constrs, Symbol.NONE, body); + } + /** Builds a ValDef node for given symbol and with given rhs. */ public ValDef ValDef(Symbol sym, Tree rhs) { ValDef tree = make.ValDef( |