From 3fe1910a3f17805ec55815ed61c86174cdf91a1c Mon Sep 17 00:00:00 2001 From: paltherr Date: Thu, 16 Sep 2004 16:03:58 +0000 Subject: - Generalized the code that transforms local va... - Generalized the code that transforms local variables of primary constructors to work for all constructors --- sources/scalac/transformer/AddConstructors.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sources/scalac/transformer/AddConstructors.java b/sources/scalac/transformer/AddConstructors.java index 2f95cbaecc..dc9e852013 100644 --- a/sources/scalac/transformer/AddConstructors.java +++ b/sources/scalac/transformer/AddConstructors.java @@ -212,9 +212,14 @@ public class AddConstructors extends GenTransformer { case ValDef(_, _, _, _): case LabelDef(_, _, _): - if (primaryInitializer != null) - if (tree.symbol().owner() != primaryInitializer) - tree.symbol().setOwner(primaryInitializer); + Symbol symbol = tree.symbol(); + if (symbol.owner().isConstructor()) { + // update symbols like x in these examples + // ex 1: class C { { val x = ...; ... } } + // ex 2: class C { def this(i: Int) { val x = i; ... } } + symbol.setOwner(getInitializer(symbol.owner())); + symbol.updateInfo(subst.apply(symbol.info())); + } return super.transform(tree); case New(Tree init): -- cgit v1.2.3