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

changeset 1945
f7f271bd74a2
parent 1918
a218f7befd55
child 1975
1ab22e60a738
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java	Sat Aug 10 16:29:26 2013 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java	Mon Aug 12 17:25:07 2013 +0100
     1.3 @@ -463,26 +463,34 @@
     1.4          return false;
     1.5      }
     1.6  
     1.7 -    /** Check for hiding.  Note that this doesn't handle multiple
     1.8 -     *  (interface) inheritance. */
     1.9      private boolean hiddenIn(ClassSymbol clazz, Types types) {
    1.10 -        if (kind == MTH && (flags() & STATIC) == 0) return false;
    1.11 -        while (true) {
    1.12 -            if (owner == clazz) return false;
    1.13 -            Scope.Entry e = clazz.members().lookup(name);
    1.14 -            while (e.scope != null) {
    1.15 -                if (e.sym == this) return false;
    1.16 -                if (e.sym.kind == kind &&
    1.17 +        Symbol sym = hiddenInInternal(clazz, types);
    1.18 +        return sym != null && sym != this;
    1.19 +    }
    1.20 +
    1.21 +    private Symbol hiddenInInternal(ClassSymbol c, Types types) {
    1.22 +        Scope.Entry e = c.members().lookup(name);
    1.23 +        while (e.scope != null) {
    1.24 +            if (e.sym.kind == kind &&
    1.25                      (kind != MTH ||
    1.26 -                     (e.sym.flags() & STATIC) != 0 &&
    1.27 -                     types.isSubSignature(e.sym.type, type)))
    1.28 -                    return true;
    1.29 -                e = e.next();
    1.30 +                    (e.sym.flags() & STATIC) != 0 &&
    1.31 +                    types.isSubSignature(e.sym.type, type))) {
    1.32 +                return e.sym;
    1.33              }
    1.34 -            Type superType = types.supertype(clazz.type);
    1.35 -            if (!superType.hasTag(CLASS)) return false;
    1.36 -            clazz = (ClassSymbol)superType.tsym;
    1.37 +            e = e.next();
    1.38          }
    1.39 +        List<Symbol> hiddenSyms = List.nil();
    1.40 +        for (Type st : types.interfaces(c.type).prepend(types.supertype(c.type))) {
    1.41 +            if (st != null && (st.hasTag(CLASS))) {
    1.42 +                Symbol sym = hiddenInInternal((ClassSymbol)st.tsym, types);
    1.43 +                if (sym != null) {
    1.44 +                    hiddenSyms = hiddenSyms.prepend(hiddenInInternal((ClassSymbol)st.tsym, types));
    1.45 +                }
    1.46 +            }
    1.47 +        }
    1.48 +        return hiddenSyms.contains(this) ?
    1.49 +                this :
    1.50 +                (hiddenSyms.isEmpty() ? null : hiddenSyms.head);
    1.51      }
    1.52  
    1.53      /** Is this symbol inherited into a given class?

mercurial