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

changeset 1415
01c9d4161882
parent 1393
d7d932236fee
child 1430
4d68e2a05b50
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Nov 16 18:27:36 2012 +0000
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Sat Nov 17 19:01:03 2012 +0000
     1.3 @@ -83,6 +83,8 @@
     1.4      final Name capturedName;
     1.5      private final FunctionDescriptorLookupError functionDescriptorLookupError;
     1.6  
     1.7 +    public final Warner noWarnings;
     1.8 +
     1.9      // <editor-fold defaultstate="collapsed" desc="Instantiating">
    1.10      public static Types instance(Context context) {
    1.11          Types instance = context.get(typesKey);
    1.12 @@ -106,6 +108,7 @@
    1.13          messages = JavacMessages.instance(context);
    1.14          diags = JCDiagnostic.Factory.instance(context);
    1.15          functionDescriptorLookupError = new FunctionDescriptorLookupError();
    1.16 +        noWarnings = new Warner(null);
    1.17      }
    1.18      // </editor-fold>
    1.19  
    1.20 @@ -296,7 +299,7 @@
    1.21       * convertions to s?
    1.22       */
    1.23      public boolean isConvertible(Type t, Type s) {
    1.24 -        return isConvertible(t, s, Warner.noWarnings);
    1.25 +        return isConvertible(t, s, noWarnings);
    1.26      }
    1.27      // </editor-fold>
    1.28  
    1.29 @@ -394,15 +397,10 @@
    1.30  
    1.31              @Override
    1.32              public boolean accepts(Symbol sym) {
    1.33 -                    return sym.kind == Kinds.MTH &&
    1.34 -                            (sym.flags() & ABSTRACT) != 0 &&
    1.35 -                            !overridesObjectMethod(origin, sym) &&
    1.36 -                            notOverridden(sym);
    1.37 -            }
    1.38 -
    1.39 -            private boolean notOverridden(Symbol msym) {
    1.40 -                Symbol impl = ((MethodSymbol)msym).implementation(origin, Types.this, false);
    1.41 -                return impl == null || (impl.flags() & ABSTRACT) != 0;
    1.42 +                return sym.kind == Kinds.MTH &&
    1.43 +                        (sym.flags() & (ABSTRACT | DEFAULT)) == ABSTRACT &&
    1.44 +                        !overridesObjectMethod(origin, sym) &&
    1.45 +                        (interfaceCandidates(origin.type, (MethodSymbol)sym).head.flags() & DEFAULT) == 0;
    1.46              }
    1.47          };
    1.48  
    1.49 @@ -593,7 +591,7 @@
    1.50       * Is t an unchecked subtype of s?
    1.51       */
    1.52      public boolean isSubtypeUnchecked(Type t, Type s) {
    1.53 -        return isSubtypeUnchecked(t, s, Warner.noWarnings);
    1.54 +        return isSubtypeUnchecked(t, s, noWarnings);
    1.55      }
    1.56      /**
    1.57       * Is t an unchecked subtype of s?
    1.58 @@ -1196,7 +1194,7 @@
    1.59  
    1.60      // <editor-fold defaultstate="collapsed" desc="isCastable">
    1.61      public boolean isCastable(Type t, Type s) {
    1.62 -        return isCastable(t, s, Warner.noWarnings);
    1.63 +        return isCastable(t, s, noWarnings);
    1.64      }
    1.65  
    1.66      /**
    1.67 @@ -1259,7 +1257,7 @@
    1.68                      return true;
    1.69  
    1.70                  if (s.tag == TYPEVAR) {
    1.71 -                    if (isCastable(t, s.getUpperBound(), Warner.noWarnings)) {
    1.72 +                    if (isCastable(t, s.getUpperBound(), noWarnings)) {
    1.73                          warnStack.head.warn(LintCategory.UNCHECKED);
    1.74                          return true;
    1.75                      } else {
    1.76 @@ -1269,7 +1267,7 @@
    1.77  
    1.78                  if (t.isCompound()) {
    1.79                      Warner oldWarner = warnStack.head;
    1.80 -                    warnStack.head = Warner.noWarnings;
    1.81 +                    warnStack.head = noWarnings;
    1.82                      if (!visit(supertype(t), s))
    1.83                          return false;
    1.84                      for (Type intf : interfaces(t)) {
    1.85 @@ -1368,7 +1366,7 @@
    1.86                  case BOT:
    1.87                      return true;
    1.88                  case TYPEVAR:
    1.89 -                    if (isCastable(s, t, Warner.noWarnings)) {
    1.90 +                    if (isCastable(s, t, noWarnings)) {
    1.91                          warnStack.head.warn(LintCategory.UNCHECKED);
    1.92                          return true;
    1.93                      } else {
    1.94 @@ -1396,7 +1394,7 @@
    1.95                  case TYPEVAR:
    1.96                      if (isSubtype(t, s)) {
    1.97                          return true;
    1.98 -                    } else if (isCastable(t.bound, s, Warner.noWarnings)) {
    1.99 +                    } else if (isCastable(t.bound, s, noWarnings)) {
   1.100                          warnStack.head.warn(LintCategory.UNCHECKED);
   1.101                          return true;
   1.102                      } else {
   1.103 @@ -1535,7 +1533,7 @@
   1.104              TypeVar tv = (TypeVar) t;
   1.105              return !isCastable(tv.bound,
   1.106                                 relaxBound(s),
   1.107 -                               Warner.noWarnings);
   1.108 +                               noWarnings);
   1.109          }
   1.110          if (s.tag != WILDCARD)
   1.111              s = upperBound(s);
   1.112 @@ -1838,7 +1836,7 @@
   1.113  
   1.114      // <editor-fold defaultstate="collapsed" desc="isAssignable">
   1.115      public boolean isAssignable(Type t, Type s) {
   1.116 -        return isAssignable(t, s, Warner.noWarnings);
   1.117 +        return isAssignable(t, s, noWarnings);
   1.118      }
   1.119  
   1.120      /**
   1.121 @@ -2149,9 +2147,9 @@
   1.122              }
   1.123          };
   1.124  
   1.125 -    public boolean isDirectSuperInterface(Type t, TypeSymbol tsym) {
   1.126 -        for (Type t2 : interfaces(tsym.type)) {
   1.127 -            if (isSameType(t, t2)) return true;
   1.128 +    public boolean isDirectSuperInterface(TypeSymbol isym, TypeSymbol origin) {
   1.129 +        for (Type i2 : interfaces(origin.type)) {
   1.130 +            if (isym == i2.tsym) return true;
   1.131          }
   1.132          return false;
   1.133      }
   1.134 @@ -2224,7 +2222,9 @@
   1.135       * Return list of bounds of the given type variable.
   1.136       */
   1.137      public List<Type> getBounds(TypeVar t) {
   1.138 -        if (t.bound.isErroneous() || !t.bound.isCompound())
   1.139 +                if (t.bound.hasTag(NONE))
   1.140 +            return List.nil();
   1.141 +        else if (t.bound.isErroneous() || !t.bound.isCompound())
   1.142              return List.of(t.bound);
   1.143          else if ((erasure(t).tsym.flags() & INTERFACE) == 0)
   1.144              return interfaces(t).prepend(supertype(t));
   1.145 @@ -2319,10 +2319,6 @@
   1.146          return false;
   1.147      }
   1.148  
   1.149 -    public boolean overridesObjectMethod(Symbol msym) {
   1.150 -        return ((MethodSymbol)msym).implementation(syms.objectType.tsym, this, true) != null;
   1.151 -    }
   1.152 -
   1.153      // <editor-fold defaultstate="collapsed" desc="Determining method implementation in given site">
   1.154      class ImplementationCache {
   1.155  
   1.156 @@ -2471,11 +2467,7 @@
   1.157  
   1.158      //where
   1.159      public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms) {
   1.160 -        return interfaceCandidates(site, ms, false);
   1.161 -    }
   1.162 -
   1.163 -    public List<MethodSymbol> interfaceCandidates(Type site, MethodSymbol ms, boolean intfOnly) {
   1.164 -        Filter<Symbol> filter = new MethodFilter(ms, site, intfOnly);
   1.165 +        Filter<Symbol> filter = new MethodFilter(ms, site);
   1.166          List<MethodSymbol> candidates = List.nil();
   1.167          for (Symbol s : membersClosure(site, false).getElements(filter)) {
   1.168              if (!site.tsym.isInterface() && !s.owner.isInterface()) {
   1.169 @@ -2514,17 +2506,14 @@
   1.170  
   1.171                  Symbol msym;
   1.172                  Type site;
   1.173 -                boolean intfOnly;
   1.174 -
   1.175 -                MethodFilter(Symbol msym, Type site, boolean intfOnly) {
   1.176 +
   1.177 +                MethodFilter(Symbol msym, Type site) {
   1.178                      this.msym = msym;
   1.179                      this.site = site;
   1.180 -                    this.intfOnly = intfOnly;
   1.181                  }
   1.182  
   1.183                  public boolean accepts(Symbol s) {
   1.184                      return s.kind == Kinds.MTH &&
   1.185 -                            (!intfOnly || s.owner.isInterface()) &&
   1.186                              s.name == msym.name &&
   1.187                              s.isInheritedIn(site.tsym, Types.this) &&
   1.188                              overrideEquivalent(memberType(site, s), memberType(site, msym));
   1.189 @@ -3462,11 +3451,11 @@
   1.190       */
   1.191      public boolean returnTypeSubstitutable(Type r1, Type r2) {
   1.192          if (hasSameArgs(r1, r2))
   1.193 -            return resultSubtype(r1, r2, Warner.noWarnings);
   1.194 +            return resultSubtype(r1, r2, noWarnings);
   1.195          else
   1.196              return covariantReturnType(r1.getReturnType(),
   1.197                                         erasure(r2.getReturnType()),
   1.198 -                                       Warner.noWarnings);
   1.199 +                                       noWarnings);
   1.200      }
   1.201  
   1.202      public boolean returnTypeSubstitutable(Type r1,

mercurial