diff options
-rw-r--r-- | sources/scalac/ast/TreeGen.java | 2 | ||||
-rw-r--r-- | sources/scalac/symtab/Symbol.java | 16 | ||||
-rw-r--r-- | sources/scalac/transformer/AddInterfaces.java | 3 | ||||
-rw-r--r-- | sources/scalac/transformer/LambdaLift.java | 2 |
4 files changed, 15 insertions, 8 deletions
diff --git a/sources/scalac/ast/TreeGen.java b/sources/scalac/ast/TreeGen.java index 47df5ae26c..5d11c4b1f1 100644 --- a/sources/scalac/ast/TreeGen.java +++ b/sources/scalac/ast/TreeGen.java @@ -559,8 +559,6 @@ public class TreeGen implements Kinds, Modifiers { Symbol sym = tree.symbol(); if (sym != null && sym.owner() == prevOwner) { sym.setOwner(newOwner); - if (sym.kind == Kinds.CLASS) - sym.constructor().setOwner(newOwner); } } return super.transform(tree); diff --git a/sources/scalac/symtab/Symbol.java b/sources/scalac/symtab/Symbol.java index f0578b8cee..53a77fb2bf 100644 --- a/sources/scalac/symtab/Symbol.java +++ b/sources/scalac/symtab/Symbol.java @@ -95,9 +95,19 @@ public abstract class Symbol implements Modifiers, Kinds { /** Set owner */ public Symbol setOwner(Symbol owner) { - this.owner = owner; + assert !isModuleClass() : Debug.show(this); + assert !isPrimaryConstructor() : Debug.show(this); + setOwner(this, owner); return this; } + private static void setOwner(Symbol symbol, Symbol owner) { + assert symbol != null; + assert symbol != Symbol.NONE; + assert symbol != Symbol.ERROR; + if (symbol.isModule()) setOwner(symbol.moduleClass(), owner); + if (symbol.isClass()) setOwner(symbol.constructor(), owner); + symbol.owner = owner; + } /** Set information, except if symbol is both initialized and locked. */ @@ -1237,7 +1247,7 @@ public class ClassSymbol extends TypeSymbol { */ public ClassSymbol(int pos, Name name, Symbol owner, int flags) { super(CLASS, pos, name, owner, flags); - this.constructor = TermSymbol.newConstructor(this, flags); + this.constructor = TermSymbol.newConstructor(this, flags & ~MODUL); this.mangled = name; } @@ -1261,7 +1271,7 @@ public class ClassSymbol extends TypeSymbol { */ public ClassSymbol(Name name, Symbol owner, ClassParser parser) { super(CLASS, Position.NOPOS, name, owner, JAVA); - this.constructor = TermSymbol.newConstructor(this, flags); + this.constructor = TermSymbol.newConstructor(this, flags & ~MODUL); this.module = TermSymbol.newCompanionModule(this, JAVA, parser.staticsParser(this)); this.mangled = name; this.setInfo(parser); diff --git a/sources/scalac/transformer/AddInterfaces.java b/sources/scalac/transformer/AddInterfaces.java index 71a3a3db52..c4a1eabe9e 100644 --- a/sources/scalac/transformer/AddInterfaces.java +++ b/sources/scalac/transformer/AddInterfaces.java @@ -663,7 +663,6 @@ class AddInterfaces extends SubstTransformer { if (ifaceToClass.containsKey(classSym.owner())) { Symbol newOwner = (Symbol)ifaceToClass.get(classSym.owner()); classSym.setOwner(newOwner); - classConstrSym.setOwner(newOwner); } Symbol[] ifaceTParams = ifaceSym.typeParams(); @@ -698,7 +697,7 @@ class AddInterfaces extends SubstTransformer { ifaceMemberSym.updateInfo(tparamsSM.apply(ifaceMemberSym.info())); if (! memberGoesInInterface(ifaceMemberSym)) { - ifaceMemberSym.setOwner(classSym); + if (!ifaceMemberSym.isPrimaryConstructor()) ifaceMemberSym.setOwner(classSym); classMembers.enterOrOverload(ifaceMemberSym); continue; } diff --git a/sources/scalac/transformer/LambdaLift.java b/sources/scalac/transformer/LambdaLift.java index 537e1f19a8..9194c32848 100644 --- a/sources/scalac/transformer/LambdaLift.java +++ b/sources/scalac/transformer/LambdaLift.java @@ -454,7 +454,7 @@ public class LambdaLift extends OwnerTransformer */ void liftSymbol(Symbol sym, Symbol[] newtparams, Symbol[] newparams) { Symbol enclClass = sym.owner().enclClass(); - sym.setOwner(enclClass); + if (!sym.isPrimaryConstructor()) sym.setOwner(enclClass); enclClass.members().enter(sym); if (sym.isMethod()) { if (newtparams.length != 0 || newparams.length != 0) { |