From 42fe3b7da729cc65595d25aa7da5df3538c5d4e8 Mon Sep 17 00:00:00 2001 From: paltherr Date: Mon, 5 May 2003 08:45:59 +0000 Subject: - Changed setOwner to automatically update the ... - Changed setOwner to automatically update the owner of the associated class (for modules) and constructor (for classes). --- sources/scalac/symtab/Symbol.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'sources/scalac/symtab') 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); -- cgit v1.2.3