src/share/classes/com/sun/tools/javac/code/Types.java

changeset 877
351027202f60
parent 858
96d4226bdd60
child 880
0c24826853b2
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Mon Feb 14 14:27:47 2011 -0800
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Feb 15 11:49:46 2011 +0000
     1.3 @@ -2023,18 +2023,22 @@
     1.4              final MethodSymbol cachedImpl;
     1.5              final Filter<Symbol> implFilter;
     1.6              final boolean checkResult;
     1.7 +            final int prevMark;
     1.8  
     1.9              public Entry(MethodSymbol cachedImpl,
    1.10                      Filter<Symbol> scopeFilter,
    1.11 -                    boolean checkResult) {
    1.12 +                    boolean checkResult,
    1.13 +                    int prevMark) {
    1.14                  this.cachedImpl = cachedImpl;
    1.15                  this.implFilter = scopeFilter;
    1.16                  this.checkResult = checkResult;
    1.17 +                this.prevMark = prevMark;
    1.18              }
    1.19  
    1.20 -            boolean matches(Filter<Symbol> scopeFilter, boolean checkResult) {
    1.21 +            boolean matches(Filter<Symbol> scopeFilter, boolean checkResult, int mark) {
    1.22                  return this.implFilter == scopeFilter &&
    1.23 -                        this.checkResult == checkResult;
    1.24 +                        this.checkResult == checkResult &&
    1.25 +                        this.prevMark == mark;
    1.26              }
    1.27          }
    1.28  
    1.29 @@ -2046,10 +2050,11 @@
    1.30                  _map.put(ms, new SoftReference<Map<TypeSymbol, Entry>>(cache));
    1.31              }
    1.32              Entry e = cache.get(origin);
    1.33 +            CompoundScope members = membersClosure(origin.type);
    1.34              if (e == null ||
    1.35 -                    !e.matches(implFilter, checkResult)) {
    1.36 -                MethodSymbol impl = implementationInternal(ms, origin, Types.this, checkResult, implFilter);
    1.37 -                cache.put(origin, new Entry(impl, implFilter, checkResult));
    1.38 +                    !e.matches(implFilter, checkResult, members.getMark())) {
    1.39 +                MethodSymbol impl = implementationInternal(ms, origin, checkResult, implFilter);
    1.40 +                cache.put(origin, new Entry(impl, implFilter, checkResult, members.getMark()));
    1.41                  return impl;
    1.42              }
    1.43              else {
    1.44 @@ -2057,8 +2062,8 @@
    1.45              }
    1.46          }
    1.47  
    1.48 -        private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, Types types, boolean checkResult, Filter<Symbol> implFilter) {
    1.49 -            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = types.supertype(t)) {
    1.50 +        private MethodSymbol implementationInternal(MethodSymbol ms, TypeSymbol origin, boolean checkResult, Filter<Symbol> implFilter) {
    1.51 +            for (Type t = origin.type; t.tag == CLASS || t.tag == TYPEVAR; t = supertype(t)) {
    1.52                  while (t.tag == TYPEVAR)
    1.53                      t = t.getUpperBound();
    1.54                  TypeSymbol c = t.tsym;
    1.55 @@ -2066,7 +2071,7 @@
    1.56                       e.scope != null;
    1.57                       e = e.next(implFilter)) {
    1.58                      if (e.sym != null &&
    1.59 -                             e.sym.overrides(ms, origin, types, checkResult))
    1.60 +                             e.sym.overrides(ms, origin, Types.this, checkResult))
    1.61                          return (MethodSymbol)e.sym;
    1.62                  }
    1.63              }
    1.64 @@ -2082,46 +2087,35 @@
    1.65      // </editor-fold>
    1.66  
    1.67      // <editor-fold defaultstate="collapsed" desc="compute transitive closure of all members in given site">
    1.68 -    public Scope membersClosure(Type site) {
    1.69 +    public CompoundScope membersClosure(Type site) {
    1.70          return membersClosure.visit(site);
    1.71      }
    1.72  
    1.73 -    UnaryVisitor<Scope> membersClosure = new UnaryVisitor<Scope>() {
    1.74 -
    1.75 -        public Scope visitType(Type t, Void s) {
    1.76 +    UnaryVisitor<CompoundScope> membersClosure = new UnaryVisitor<CompoundScope>() {
    1.77 +
    1.78 +        public CompoundScope visitType(Type t, Void s) {
    1.79              return null;
    1.80          }
    1.81  
    1.82          @Override
    1.83 -        public Scope visitClassType(ClassType t, Void s) {
    1.84 +        public CompoundScope visitClassType(ClassType t, Void s) {
    1.85              ClassSymbol csym = (ClassSymbol)t.tsym;
    1.86              if (csym.membersClosure == null) {
    1.87 -                Scope membersClosure = new Scope(csym);
    1.88 +                CompoundScope membersClosure = new CompoundScope(csym);
    1.89                  for (Type i : interfaces(t)) {
    1.90 -                    enterAll(visit(i), membersClosure);
    1.91 +                    membersClosure.addSubScope(visit(i));
    1.92                  }
    1.93 -                enterAll(visit(supertype(t)), membersClosure);
    1.94 -                enterAll(csym.members(), membersClosure);
    1.95 +                membersClosure.addSubScope(visit(supertype(t)));
    1.96 +                membersClosure.addSubScope(csym.members());
    1.97                  csym.membersClosure = membersClosure;
    1.98              }
    1.99              return csym.membersClosure;
   1.100          }
   1.101  
   1.102          @Override
   1.103 -        public Scope visitTypeVar(TypeVar t, Void s) {
   1.104 +        public CompoundScope visitTypeVar(TypeVar t, Void s) {
   1.105              return visit(t.getUpperBound());
   1.106          }
   1.107 -
   1.108 -        public void enterAll(Scope s, Scope to) {
   1.109 -            if (s == null) return;
   1.110 -            List<Symbol> syms = List.nil();
   1.111 -            for (Scope.Entry e = s.elems ; e != null ; e = e.sibling) {
   1.112 -                syms = syms.prepend(e.sym);
   1.113 -            }
   1.114 -            for (Symbol sym : syms) {
   1.115 -                to.enter(sym);
   1.116 -            }
   1.117 -        }
   1.118      };
   1.119      // </editor-fold>
   1.120  

mercurial