src/share/classes/com/sun/tools/javac/comp/Attr.java

changeset 2187
4788eb38cac5
parent 2179
8b4e1421a9b7
child 2191
e79d6425f1c4
     1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Sat Nov 09 15:24:38 2013 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Nov 11 09:47:46 2013 -0500
     1.3 @@ -58,7 +58,6 @@
     1.4  import static com.sun.tools.javac.code.Kinds.ERRONEOUS;
     1.5  import static com.sun.tools.javac.code.TypeTag.*;
     1.6  import static com.sun.tools.javac.code.TypeTag.WILDCARD;
     1.7 -import static com.sun.tools.javac.code.TypeTag.ARRAY;
     1.8  import static com.sun.tools.javac.tree.JCTree.Tag.*;
     1.9  
    1.10  /** This is the main context-dependent analysis phase in GJC. It
    1.11 @@ -806,44 +805,33 @@
    1.12          Type t = tree.type != null ?
    1.13              tree.type :
    1.14              attribType(tree, env);
    1.15 -        return checkBase(t, tree, env, classExpected, interfaceExpected, false, checkExtensible);
    1.16 +        return checkBase(t, tree, env, classExpected, interfaceExpected, checkExtensible);
    1.17      }
    1.18      Type checkBase(Type t,
    1.19                     JCTree tree,
    1.20                     Env<AttrContext> env,
    1.21                     boolean classExpected,
    1.22 -                   boolean interfacesOnlyExpected,
    1.23 -                   boolean interfacesOrArraysExpected,
    1.24 +                   boolean interfaceExpected,
    1.25                     boolean checkExtensible) {
    1.26          if (t.isErroneous())
    1.27              return t;
    1.28 -        if (t.hasTag(TYPEVAR) && !classExpected &&
    1.29 -            !interfacesOrArraysExpected && !interfacesOnlyExpected) {
    1.30 +        if (t.hasTag(TYPEVAR) && !classExpected && !interfaceExpected) {
    1.31              // check that type variable is already visible
    1.32              if (t.getUpperBound() == null) {
    1.33                  log.error(tree.pos(), "illegal.forward.ref");
    1.34                  return types.createErrorType(t);
    1.35              }
    1.36 -        } else if (classExpected) {
    1.37 +        } else {
    1.38              t = chk.checkClassType(tree.pos(), t, checkExtensible|!allowGenerics);
    1.39 -        } else {
    1.40 -            t = chk.checkClassOrArrayType(tree.pos(), t,
    1.41 -                                          checkExtensible|!allowGenerics);
    1.42          }
    1.43 -        if (interfacesOnlyExpected && !t.tsym.isInterface()) {
    1.44 +        if (interfaceExpected && (t.tsym.flags() & INTERFACE) == 0) {
    1.45              log.error(tree.pos(), "intf.expected.here");
    1.46              // return errType is necessary since otherwise there might
    1.47              // be undetected cycles which cause attribution to loop
    1.48              return types.createErrorType(t);
    1.49 -        } else if (interfacesOrArraysExpected &&
    1.50 -            !(t.tsym.isInterface() || t.getTag() == ARRAY)) {
    1.51 -            log.error(tree.pos(), "intf.or.array.expected.here");
    1.52 -            // return errType is necessary since otherwise there might
    1.53 -            // be undetected cycles which cause attribution to loop
    1.54 -            return types.createErrorType(t);
    1.55          } else if (checkExtensible &&
    1.56                     classExpected &&
    1.57 -                   t.tsym.isInterface()) {
    1.58 +                   (t.tsym.flags() & INTERFACE) != 0) {
    1.59              log.error(tree.pos(), "no.intf.expected.here");
    1.60              return types.createErrorType(t);
    1.61          }
    1.62 @@ -855,12 +843,6 @@
    1.63          chk.checkNonCyclic(tree.pos(), t);
    1.64          return t;
    1.65      }
    1.66 -    //where
    1.67 -        private Object asTypeParam(Type t) {
    1.68 -            return (t.hasTag(TYPEVAR))
    1.69 -                                    ? diags.fragment("type.parameter", t)
    1.70 -                                    : t;
    1.71 -        }
    1.72  
    1.73      Type attribIdentAsEnumType(Env<AttrContext> env, JCIdent id) {
    1.74          Assert.check((env.enclClass.sym.flags() & ENUM) != 0);
    1.75 @@ -3985,7 +3967,7 @@
    1.76          Set<Type> boundSet = new HashSet<Type>();
    1.77          if (bounds.nonEmpty()) {
    1.78              // accept class or interface or typevar as first bound.
    1.79 -            bounds.head.type = checkBase(bounds.head.type, bounds.head, env, false, false, false, false);
    1.80 +            bounds.head.type = checkBase(bounds.head.type, bounds.head, env, false, false, false);
    1.81              boundSet.add(types.erasure(bounds.head.type));
    1.82              if (bounds.head.type.isErroneous()) {
    1.83                  return bounds.head.type;
    1.84 @@ -4001,7 +3983,7 @@
    1.85                  // if first bound was a class or interface, accept only interfaces
    1.86                  // as further bounds.
    1.87                  for (JCExpression bound : bounds.tail) {
    1.88 -                    bound.type = checkBase(bound.type, bound, env, false, false, true, false);
    1.89 +                    bound.type = checkBase(bound.type, bound, env, false, true, false);
    1.90                      if (bound.type.isErroneous()) {
    1.91                          bounds = List.of(bound);
    1.92                      }

mercurial