langtools/src/share/classes/com/sun/tools/javac/code/Types.java
changeset 8427 703181b01773
parent 8242 3873b4aaf4a8
child 8430 be3e5581ea25
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Feb 14 14:27:47 2011 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Feb 15 11:49:46 2011 +0000
@@ -2023,18 +2023,22 @@
             final MethodSymbol cachedImpl;
             final Filter<Symbol> implFilter;
             final boolean checkResult;
+            final int prevMark;
 
             public Entry(MethodSymbol cachedImpl,
                     Filter<Symbol> scopeFilter,
-                    boolean checkResult) {
+                    boolean checkResult,
+                    int prevMark) {
                 this.cachedImpl = cachedImpl;
                 this.implFilter = scopeFilter;
                 this.checkResult = checkResult;
+                this.prevMark = prevMark;
             }
 
-            boolean matches(Filter<Symbol> scopeFilter, boolean checkResult) {
+            boolean matches(Filter<Symbol> scopeFilter, boolean checkResult, int mark) {
                 return this.implFilter == scopeFilter &&
-                        this.checkResult == checkResult;
+                        this.checkResult == checkResult &&
+                        this.prevMark == mark;
             }
         }
 
@@ -2046,10 +2050,11 @@
                 _map.put(ms, new SoftReference<Map<TypeSymbol, Entry>>(cache));
             }
             Entry e = cache.get(origin);
+            CompoundScope members = membersClosure(origin.type);
             if (e == null ||
-                    !e.matches(implFilter, checkResult)) {
-                MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter);
-                cache.put(origin, new Entry(impl, implFilter, checkResult));
+                    !e.matches(implFilter, checkResult, members.getMark())) {
+                MethodSymbol impl = implementationInternal(ms, origin, checkResult, implFilter);
+                cache.put(origin, new Entry(impl, implFilter, checkResult, members.getMark()));
                 return impl;
             }
             else {
@@ -2057,8 +2062,8 @@
             }
         }
 
-        private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
-            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = types.supertype(t)) {
+        private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
+            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = supertype(t)) {
                 while (t.tag == TYPEVAR)
                     t = t.getUpperBound();
                 TypeSymbol c = t.tsym;
@@ -2066,7 +2071,7 @@
                      e.scope != null;
                      e = e.next(implFilter)) {
                     if (e.sym != null &&
-                             e.sym.overrides(ms, origin, types, checkResult))
+                             e.sym.overrides(ms, origin, Types.this, checkResult))
                         return (MethodSymbol)e.sym;
                 }
             }
@@ -2082,46 +2087,35 @@
     // </editor-fold>
 
     // <editor-fold defaultstate="collapsed" desc="compute transitive closure of all members in given site">
-    public Scope membersClosure(Type site) {
+    public CompoundScope membersClosure(Type site) {
         return membersClosure.visit(site);
     }
 
-    UnaryVisitor<Scope> membersClosure = new UnaryVisitor<Scope>() {
-
-        public Scope visitType(Type t, Void s) {
+    UnaryVisitor<CompoundScope> membersClosure = new UnaryVisitor<CompoundScope>() {
+
+        public CompoundScope visitType(Type t, Void s) {
             return null;
         }
 
         @Override
-        public Scope visitClassType(ClassType t, Void s) {
+        public CompoundScope visitClassType(ClassType t, Void s) {
             ClassSymbol csym = (ClassSymbol)t.tsym;
             if (csym.membersClosure == null) {
-                Scope membersClosure = new Scope(csym);
+                CompoundScope membersClosure = new CompoundScope(csym);
                 for (Type i : interfaces(t)) {
-                    enterAll(visit(i), membersClosure);
+                    membersClosure.addSubScope(visit(i));
                 }
-                enterAll(visit(supertype(t)), membersClosure);
-                enterAll(csym.members(), membersClosure);
+                membersClosure.addSubScope(visit(supertype(t)));
+                membersClosure.addSubScope(csym.members());
                 csym.membersClosure = membersClosure;
             }
             return csym.membersClosure;
         }
 
         @Override
-        public Scope visitTypeVar(TypeVar t, Void s) {
+        public CompoundScope visitTypeVar(TypeVar t, Void s) {
             return visit(t.getUpperBound());
         }
-
-        public void enterAll(Scope s, Scope to) {
-            if (s == null) return;
-            List<Symbol> syms = List.nil();
-            for (Scope.Entry e = s.elems ; e != null ; e = e.sibling) {
-                syms = syms.prepend(e.sym);
-            }
-            for (Symbol sym : syms) {
-                to.enter(sym);
-            }
-        }
     };
     // </editor-fold>