diff options
Diffstat (limited to 'sources/scalac/symtab/Scope.java')
-rw-r--r-- | sources/scalac/symtab/Scope.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/sources/scalac/symtab/Scope.java b/sources/scalac/symtab/Scope.java index f1fa915c55..c205342011 100644 --- a/sources/scalac/symtab/Scope.java +++ b/sources/scalac/symtab/Scope.java @@ -178,11 +178,25 @@ public class Scope { /** enter a symbol */ public Scope enter(Symbol sym) { + assert lookupEntry(sym.name).owner != this : Debug.show(sym); return enter(new Entry(sym, this)); } public Scope enterOrOverload(Symbol sym) { Entry e = lookupEntry(sym.name); + /* !!! + if (e == Entry.NONE) { + return enter(sym); + } else { + sym = e.sym.overloadWith(sym); + if (e.owner == this) { + e.setSymbol(sym); + return this; + } else { + return enter(new Entry(sym, this)); + } + } + */ if (e.owner == this && (sym.flags & Modifiers.PRIVATE) == 0) { e.setSymbol(e.sym.overloadWith(sym)); return this; @@ -229,6 +243,17 @@ public class Scope { elemsCache = null; } + public boolean contains(Symbol sym) { + Entry e = lookupEntry(sym.name); + if (e.sym == sym) return true; + switch (e.sym.type()) { + case OverloadedType(Symbol[] alts, _): + for (int i = 0; i < alts.length; i++) + if (alts[i] == sym) return true; + } + return false; + } + /** lookup a symbol */ public Symbol lookup(Name name) { @@ -267,6 +292,11 @@ public class Scope { */ public SymbolIterator iterator() { return new MySymbols(); } + public SymbolIterator iterator(boolean unload) { + SymbolIterator iterator = iterator(); + return unload ? new UnloadIterator(iterator) : iterator; + } + class MySymbols extends SymbolIterator { private int index; |