diff options
Diffstat (limited to 'sources/scalac/transformer/AddConstructors.java')
-rw-r--r-- | sources/scalac/transformer/AddConstructors.java | 11 |
1 files 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): |