1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Oct 01 17:03:31 2013 +0400 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Oct 01 17:41:57 2013 -0400 1.3 @@ -58,6 +58,7 @@ 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 @@ -797,28 +798,32 @@ 1.12 JCTree tree, 1.13 Env<AttrContext> env, 1.14 boolean classExpected, 1.15 - boolean interfaceExpected, 1.16 + boolean interfaceOrArrayExpected, 1.17 boolean checkExtensible) { 1.18 if (t.isErroneous()) 1.19 return t; 1.20 - if (t.hasTag(TYPEVAR) && !classExpected && !interfaceExpected) { 1.21 + if (t.hasTag(TYPEVAR) && !classExpected && !interfaceOrArrayExpected) { 1.22 // check that type variable is already visible 1.23 if (t.getUpperBound() == null) { 1.24 log.error(tree.pos(), "illegal.forward.ref"); 1.25 return types.createErrorType(t); 1.26 } 1.27 + } else if (classExpected) { 1.28 + t = chk.checkClassType(tree.pos(), t, checkExtensible|!allowGenerics); 1.29 } else { 1.30 - t = chk.checkClassType(tree.pos(), t, checkExtensible|!allowGenerics); 1.31 + t = chk.checkClassOrArrayType(tree.pos(), t, 1.32 + checkExtensible|!allowGenerics); 1.33 } 1.34 - if (interfaceExpected && (t.tsym.flags() & INTERFACE) == 0) { 1.35 + if (interfaceOrArrayExpected && 1.36 + !(t.tsym.isInterface() || t.getTag() == ARRAY)) { 1.37 log.error(tree.pos(), "intf.expected.here"); 1.38 // return errType is necessary since otherwise there might 1.39 // be undetected cycles which cause attribution to loop 1.40 return types.createErrorType(t); 1.41 } else if (checkExtensible && 1.42 classExpected && 1.43 - (t.tsym.flags() & INTERFACE) != 0) { 1.44 - log.error(tree.pos(), "no.intf.expected.here"); 1.45 + t.tsym.isInterface()) { 1.46 + log.error(tree.pos(), "no.intf.expected.here"); 1.47 return types.createErrorType(t); 1.48 } 1.49 if (checkExtensible && 1.50 @@ -829,6 +834,12 @@ 1.51 chk.checkNonCyclic(tree.pos(), t); 1.52 return t; 1.53 } 1.54 + //where 1.55 + private Object asTypeParam(Type t) { 1.56 + return (t.hasTag(TYPEVAR)) 1.57 + ? diags.fragment("type.parameter", t) 1.58 + : t; 1.59 + } 1.60 1.61 Type attribIdentAsEnumType(Env<AttrContext> env, JCIdent id) { 1.62 Assert.check((env.enclClass.sym.flags() & ENUM) != 0);