summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaltherr <paltherr@epfl.ch>2003-12-16 07:39:45 +0000
committerpaltherr <paltherr@epfl.ch>2003-12-16 07:39:45 +0000
commit76d02d660b9fd2d4e3418ce00fa8b6b6f3ed7575 (patch)
tree4ac2eaa85d632d2d652bc5371bb75e18cb5544ff
parent67bb1e7543443fcfcf330692109e023a7aca7a81 (diff)
downloadscala-76d02d660b9fd2d4e3418ce00fa8b6b6f3ed7575.tar.gz
scala-76d02d660b9fd2d4e3418ce00fa8b6b6f3ed7575.tar.bz2
scala-76d02d660b9fd2d4e3418ce00fa8b6b6f3ed7575.zip
- Changed some code to change owner of ValDefs ...
- Changed some code to change owner of ValDefs and LabelDefs moved into primary initializer
-rw-r--r--sources/scalac/transformer/AddConstructors.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/sources/scalac/transformer/AddConstructors.java b/sources/scalac/transformer/AddConstructors.java
index 374851359c..ca406bced9 100644
--- a/sources/scalac/transformer/AddConstructors.java
+++ b/sources/scalac/transformer/AddConstructors.java
@@ -81,6 +81,9 @@ public class AddConstructors extends GenTransformer {
/** A constructor to initializer parameter substitution */
private final SymbolSubstTypeMap subst;
+ /** The current primary initializer or null */
+ private Symbol primaryInitializer;
+
public AddConstructors(Global global, HashMap initializers) {
super(global);
this.initializers = initializers;
@@ -237,13 +240,23 @@ public class AddConstructors extends GenTransformer {
subst.insertSymbol(
constructor.valueParams(),
initializer.valueParams());
+ if (constructor.isPrimaryConstructor())
+ primaryInitializer = initializer;
rhs = transform(rhs);
+ primaryInitializer = null;
subst.removeSymbol(constructor.valueParams());
subst.removeSymbol(constructor.typeParams());
// add consistent result expression
rhs = gen.mkBlock(new Tree[] { rhs, gen.mkUnitLit(rhs.pos) });
return gen.DefDef(initializer, rhs);
+ case ValDef(_, _, _, _):
+ case LabelDef(_, _, _):
+ if (primaryInitializer != null)
+ if (tree.symbol().owner() != primaryInitializer)
+ tree.symbol().setOwner(primaryInitializer);
+ return super.transform(tree);
+
case New(Template(Tree[] parents, _)):
return gen.New(transform(parents[0], true));