summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sources/scalac/symtab/Scope.java15
1 files changed, 13 insertions, 2 deletions
diff --git a/sources/scalac/symtab/Scope.java b/sources/scalac/symtab/Scope.java
index 64e06b61e6..477144cd3a 100644
--- a/sources/scalac/symtab/Scope.java
+++ b/sources/scalac/symtab/Scope.java
@@ -77,18 +77,19 @@ public class Scope {
/** The owner of the entry;
*/
- public Scope owner;
+ public final Scope owner;
Entry(Symbol sym, Scope owner) {
- if (sym == null) throw new ApplicationError();
this.sym = sym;
this.owner = owner;
this.next = owner.elems;
+ if (sym == null) throw new ApplicationError();
owner.elems = this;
}
private Entry() {
this.sym = Symbol.NONE;
+ this.owner = null;
}
public Entry setSymbol(Symbol sym) {
@@ -154,6 +155,16 @@ public class Scope {
enter(members[i]);
}
+ /** Returns a new scope with the same content as this one. */
+ public Scope cloneScope() {
+ int size = 0;
+ Scope clone = new Scope();
+ for (Entry e = elems; e != Entry.NONE; e = e.next, size++)
+ new Entry(e.sym, clone);
+ if (size >= MIN_HASH) clone.createHash();
+ return clone;
+ }
+
/** the number of entries in this scope
*/
int size() {