Wed, 14 Apr 2010 12:31:55 +0100
6939620: Switch to 'complex' diamond inference scheme
Summary: Implement new inference scheme for diamond operator that takes into account type of actual arguments supplied to constructor
Reviewed-by: jjg, darcy
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Source.java Wed Apr 14 12:23:29 2010 +0100 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Source.java Wed Apr 14 12:31:55 2010 +0100 1.3 @@ -122,6 +122,9 @@ 1.4 public boolean allowGenerics() { 1.5 return compareTo(JDK1_5) >= 0; 1.6 } 1.7 + public boolean allowDiamond() { 1.8 + return compareTo(JDK1_7) >= 0; 1.9 + } 1.10 public boolean allowEnums() { 1.11 return compareTo(JDK1_5) >= 0; 1.12 }
2.1 --- a/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Apr 14 12:23:29 2010 +0100 2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Symbol.java Wed Apr 14 12:31:55 2010 +0100 2.3 @@ -225,6 +225,13 @@ 2.4 (owner.kind == TYP && owner.isLocal()); 2.5 } 2.6 2.7 + /** Has this symbol an empty name? This includes anonymous 2.8 + * inner classses. 2.9 + */ 2.10 + public boolean isAnonymous() { 2.11 + return name.isEmpty(); 2.12 + } 2.13 + 2.14 /** Is this symbol a constructor? 2.15 */ 2.16 public boolean isConstructor() {
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Apr 14 12:23:29 2010 +0100 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Apr 14 12:31:55 2010 +0100 3.3 @@ -72,6 +72,7 @@ 3.4 final Log log; 3.5 final Symtab syms; 3.6 final Resolve rs; 3.7 + final Infer infer; 3.8 final Check chk; 3.9 final MemberEnter memberEnter; 3.10 final TreeMaker make; 3.11 @@ -100,6 +101,7 @@ 3.12 memberEnter = MemberEnter.instance(context); 3.13 make = TreeMaker.instance(context); 3.14 enter = Enter.instance(context); 3.15 + infer = Infer.instance(context); 3.16 cfolder = ConstFold.instance(context); 3.17 target = Target.instance(context); 3.18 types = Types.instance(context); 3.19 @@ -425,7 +427,14 @@ 3.20 /** Derived visitor method: attribute a type tree. 3.21 */ 3.22 Type attribType(JCTree tree, Env<AttrContext> env) { 3.23 - Type result = attribTree(tree, env, TYP, Type.noType); 3.24 + Type result = attribType(tree, env, Type.noType); 3.25 + return result; 3.26 + } 3.27 + 3.28 + /** Derived visitor method: attribute a type tree. 3.29 + */ 3.30 + Type attribType(JCTree tree, Env<AttrContext> env, Type pt) { 3.31 + Type result = attribTree(tree, env, TYP, pt); 3.32 return result; 3.33 } 3.34 3.35 @@ -532,6 +541,7 @@ 3.36 } 3.37 3.38 /** Attribute type reference in an `extends' or `implements' clause. 3.39 + * Supertypes of anonymous inner classes are usually already attributed. 3.40 * 3.41 * @param tree The tree making up the type reference. 3.42 * @param env The environment current at the reference. 3.43 @@ -543,7 +553,9 @@ 3.44 boolean classExpected, 3.45 boolean interfaceExpected, 3.46 boolean checkExtensible) { 3.47 - Type t = attribType(tree, env); 3.48 + Type t = tree.type != null ? 3.49 + tree.type : 3.50 + attribType(tree, env); 3.51 return checkBase(t, tree, env, classExpected, interfaceExpected, checkExtensible); 3.52 } 3.53 Type checkBase(Type t, 3.54 @@ -1448,13 +1460,16 @@ 3.55 ((JCTypeApply) clazz).arguments); 3.56 else 3.57 clazz = clazzid1; 3.58 -// System.out.println(clazz + " generated.");//DEBUG 3.59 } 3.60 3.61 // Attribute clazz expression and store 3.62 // symbol + type back into the attributed tree. 3.63 - Type clazztype = chk.checkClassType( 3.64 - tree.clazz.pos(), attribType(clazz, env), true); 3.65 + Type clazztype = attribType(clazz, env); 3.66 + Pair<Scope,Scope> mapping = getSyntheticScopeMapping((ClassType)clazztype); 3.67 + if (!TreeInfo.isDiamond(tree)) { 3.68 + clazztype = chk.checkClassType( 3.69 + tree.clazz.pos(), clazztype, true); 3.70 + } 3.71 chk.validate(clazz, localEnv); 3.72 if (tree.encl != null) { 3.73 // We have to work in this case to store 3.74 @@ -1479,6 +1494,11 @@ 3.75 List<Type> argtypes = attribArgs(tree.args, localEnv); 3.76 List<Type> typeargtypes = attribTypes(tree.typeargs, localEnv); 3.77 3.78 + if (TreeInfo.isDiamond(tree)) { 3.79 + clazztype = attribDiamond(localEnv, tree, clazztype, mapping, argtypes, typeargtypes, true); 3.80 + clazz.type = clazztype; 3.81 + } 3.82 + 3.83 // If we have made no mistakes in the class type... 3.84 if (clazztype.tag == CLASS) { 3.85 // Enums may not be instantiated except implicitly 3.86 @@ -1516,12 +1536,12 @@ 3.87 tree.constructor = rs.resolveConstructor( 3.88 tree.pos(), localEnv, clazztype, argtypes, typeargtypes); 3.89 tree.constructorType = checkMethod(clazztype, 3.90 - tree.constructor, 3.91 - localEnv, 3.92 - tree.args, 3.93 - argtypes, 3.94 - typeargtypes, 3.95 - localEnv.info.varArgs); 3.96 + tree.constructor, 3.97 + localEnv, 3.98 + tree.args, 3.99 + argtypes, 3.100 + typeargtypes, 3.101 + localEnv.info.varArgs); 3.102 if (localEnv.info.varArgs) 3.103 assert tree.constructorType.isErroneous() || tree.varargsElement != null; 3.104 } 3.105 @@ -1606,6 +1626,136 @@ 3.106 chk.validate(tree.typeargs, localEnv); 3.107 } 3.108 3.109 + Type attribDiamond(Env<AttrContext> env, 3.110 + JCNewClass tree, 3.111 + Type clazztype, 3.112 + Pair<Scope, Scope> mapping, 3.113 + List<Type> argtypes, 3.114 + List<Type> typeargtypes, 3.115 + boolean reportErrors) { 3.116 + if (clazztype.isErroneous()) { 3.117 + //if the type of the instance creation expression is erroneous 3.118 + //return the erroneous type itself 3.119 + return clazztype; 3.120 + } 3.121 + else if (clazztype.isInterface()) { 3.122 + //if the type of the instance creation expression is an interface 3.123 + //skip the method resolution step (JLS 15.12.2.7). The type to be 3.124 + //inferred is of the kind <X1,X2, ... Xn>C<X1,X2, ... Xn> 3.125 + clazztype = new ForAll(clazztype.tsym.type.allparams(), 3.126 + clazztype.tsym.type); 3.127 + } else { 3.128 + //if the type of the instance creation expression is a class type 3.129 + //apply method resolution inference (JLS 15.12.2.7). The return type 3.130 + //of the resolved constructor will be a partially instantiated type 3.131 + ((ClassSymbol) clazztype.tsym).members_field = mapping.snd; 3.132 + Symbol constructor; 3.133 + try { 3.134 + constructor = rs.resolveDiamond(tree.pos(), 3.135 + env, 3.136 + clazztype.tsym.type, 3.137 + argtypes, 3.138 + typeargtypes, reportErrors); 3.139 + } finally { 3.140 + ((ClassSymbol) clazztype.tsym).members_field = mapping.fst; 3.141 + } 3.142 + if (constructor.kind == MTH) { 3.143 + ClassType ct = new ClassType(clazztype.getEnclosingType(), 3.144 + clazztype.tsym.type.getTypeArguments(), 3.145 + clazztype.tsym); 3.146 + clazztype = checkMethod(ct, 3.147 + constructor, 3.148 + env, 3.149 + tree.args, 3.150 + argtypes, 3.151 + typeargtypes, 3.152 + env.info.varArgs).getReturnType(); 3.153 + } else { 3.154 + clazztype = syms.errType; 3.155 + } 3.156 + } 3.157 + if (clazztype.tag == FORALL && !pt.isErroneous()) { 3.158 + //if the resolved constructor's return type has some uninferred 3.159 + //type-variables, infer them using the expected type and declared 3.160 + //bounds (JLS 15.12.2.8). 3.161 + try { 3.162 + clazztype = infer.instantiateExpr((ForAll) clazztype, 3.163 + pt.tag == NONE ? syms.objectType : pt, 3.164 + Warner.noWarnings); 3.165 + } catch (Infer.InferenceException ex) { 3.166 + //an error occurred while inferring uninstantiated type-variables 3.167 + //we need to optionally report an error 3.168 + if (reportErrors) { 3.169 + log.error(tree.clazz.pos(), 3.170 + "cant.apply.diamond.1", 3.171 + diags.fragment("diamond", clazztype.tsym), 3.172 + ex.diagnostic); 3.173 + } 3.174 + } 3.175 + } 3.176 + if (reportErrors) { 3.177 + clazztype = chk.checkClassType(tree.clazz.pos(), 3.178 + clazztype, 3.179 + true); 3.180 + if (clazztype.tag == CLASS) { 3.181 + List<Type> invalidDiamondArgs = chk.checkDiamond((ClassType)clazztype); 3.182 + if (!clazztype.isErroneous() && invalidDiamondArgs.nonEmpty()) { 3.183 + //one or more types inferred in the previous steps is either a 3.184 + //captured type or an intersection type --- we need to report an error. 3.185 + String subkey = invalidDiamondArgs.size() > 1 ? 3.186 + "diamond.invalid.args" : 3.187 + "diamond.invalid.arg"; 3.188 + //The error message is of the kind: 3.189 + // 3.190 + //cannot infer type arguments for {clazztype}<>; 3.191 + //reason: {subkey} 3.192 + // 3.193 + //where subkey is a fragment of the kind: 3.194 + // 3.195 + //type argument(s) {invalidDiamondArgs} inferred for {clazztype}<> is not allowed in this context 3.196 + log.error(tree.clazz.pos(), 3.197 + "cant.apply.diamond.1", 3.198 + diags.fragment("diamond", clazztype.tsym), 3.199 + diags.fragment(subkey, 3.200 + invalidDiamondArgs, 3.201 + diags.fragment("diamond", clazztype.tsym))); 3.202 + } 3.203 + } 3.204 + } 3.205 + return clazztype; 3.206 + } 3.207 + 3.208 + /** Creates a synthetic scope containing fake generic constructors. 3.209 + * Assuming that the original scope contains a constructor of the kind: 3.210 + * Foo(X x, Y y), where X,Y are class type-variables declared in Foo, 3.211 + * the synthetic scope is added a generic constructor of the kind: 3.212 + * <X,Y>Foo<X,Y>(X x, Y y). This is crucial in order to enable diamond 3.213 + * inference. The inferred return type of the synthetic constructor IS 3.214 + * the inferred type for the diamond operator. 3.215 + */ 3.216 + private Pair<Scope, Scope> getSyntheticScopeMapping(ClassType ctype) { 3.217 + Pair<Scope, Scope> mapping = 3.218 + new Pair<Scope, Scope>(ctype.tsym.members(), new Scope(ctype.tsym)); 3.219 + List<Type> typevars = ctype.tsym.type.getTypeArguments(); 3.220 + for (Scope.Entry e = mapping.fst.lookup(names.init); 3.221 + e.scope != null; 3.222 + e = e.next()) { 3.223 + MethodSymbol newConstr = (MethodSymbol) e.sym.clone(ctype.tsym); 3.224 + newConstr.name = names.init; 3.225 + List<Type> oldTypeargs = List.nil(); 3.226 + if (newConstr.type.tag == FORALL) { 3.227 + oldTypeargs = ((ForAll) newConstr.type).tvars; 3.228 + } 3.229 + newConstr.type = new MethodType(newConstr.type.getParameterTypes(), 3.230 + new ClassType(ctype.getEnclosingType(), ctype.tsym.type.getTypeArguments(), ctype.tsym), 3.231 + newConstr.type.getThrownTypes(), 3.232 + syms.methodClass); 3.233 + newConstr.type = new ForAll(typevars.prependList(oldTypeargs), newConstr.type); 3.234 + mapping.snd.enter(newConstr); 3.235 + } 3.236 + return mapping; 3.237 + } 3.238 + 3.239 /** Make an attributed null check tree. 3.240 */ 3.241 public JCExpression makeNullCheck(JCExpression arg) { 3.242 @@ -2547,7 +2697,7 @@ 3.243 if (clazztype.tag == CLASS) { 3.244 List<Type> formals = clazztype.tsym.type.getTypeArguments(); 3.245 3.246 - if (actuals.length() == formals.length()) { 3.247 + if (actuals.length() == formals.length() || actuals.length() == 0) { 3.248 List<Type> a = actuals; 3.249 List<Type> f = formals; 3.250 while (a.nonEmpty()) { 3.251 @@ -2788,9 +2938,12 @@ 3.252 3.253 // Validate type parameters, supertype and interfaces. 3.254 attribBounds(tree.typarams); 3.255 - chk.validate(tree.typarams, env); 3.256 - chk.validate(tree.extending, env); 3.257 - chk.validate(tree.implementing, env); 3.258 + if (!c.isAnonymous()) { 3.259 + //already checked if anonymous 3.260 + chk.validate(tree.typarams, env); 3.261 + chk.validate(tree.extending, env); 3.262 + chk.validate(tree.implementing, env); 3.263 + } 3.264 3.265 // If this is a non-abstract class, check that it has no abstract 3.266 // methods or unimplemented methods of an implemented interface.
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Apr 14 12:23:29 2010 +0100 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Wed Apr 14 12:31:55 2010 +0100 4.3 @@ -640,6 +640,43 @@ 4.4 return true; 4.5 } 4.6 4.7 + /** Check that the type inferred using the diamond operator does not contain 4.8 + * non-denotable types such as captured types or intersection types. 4.9 + * @param t the type inferred using the diamond operator 4.10 + */ 4.11 + List<Type> checkDiamond(ClassType t) { 4.12 + DiamondTypeChecker dtc = new DiamondTypeChecker(); 4.13 + ListBuffer<Type> buf = ListBuffer.lb(); 4.14 + for (Type arg : t.getTypeArguments()) { 4.15 + if (!dtc.visit(arg, null)) { 4.16 + buf.append(arg); 4.17 + } 4.18 + } 4.19 + return buf.toList(); 4.20 + } 4.21 + 4.22 + static class DiamondTypeChecker extends Types.SimpleVisitor<Boolean, Void> { 4.23 + public Boolean visitType(Type t, Void s) { 4.24 + return true; 4.25 + } 4.26 + @Override 4.27 + public Boolean visitClassType(ClassType t, Void s) { 4.28 + if (t.isCompound()) { 4.29 + return false; 4.30 + } 4.31 + for (Type targ : t.getTypeArguments()) { 4.32 + if (!visit(targ, s)) { 4.33 + return false; 4.34 + } 4.35 + } 4.36 + return true; 4.37 + } 4.38 + @Override 4.39 + public Boolean visitCapturedType(CapturedType t, Void s) { 4.40 + return false; 4.41 + } 4.42 + } 4.43 + 4.44 /** Check that given modifiers are legal for given symbol and 4.45 * return modifiers together with any implicit modififiers for that symbol. 4.46 * Warning: we can't use flags() here since this method
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Apr 14 12:23:29 2010 +0100 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Wed Apr 14 12:31:55 2010 +0100 5.3 @@ -788,6 +788,8 @@ 5.4 operator); 5.5 } 5.6 } 5.7 + if (name == names.init) 5.8 + break; 5.9 //- System.out.println(" - " + bestSoFar); 5.10 if (abstractok) { 5.11 Symbol concrete = methodNotFound; 5.12 @@ -1409,6 +1411,48 @@ 5.13 return sym; 5.14 } 5.15 5.16 + /** Resolve constructor using diamond inference. 5.17 + * @param pos The position to use for error reporting. 5.18 + * @param env The environment current at the constructor invocation. 5.19 + * @param site The type of class for which a constructor is searched. 5.20 + * The scope of this class has been touched in attribution. 5.21 + * @param argtypes The types of the constructor invocation's value 5.22 + * arguments. 5.23 + * @param typeargtypes The types of the constructor invocation's type 5.24 + * arguments. 5.25 + */ 5.26 + Symbol resolveDiamond(DiagnosticPosition pos, 5.27 + Env<AttrContext> env, 5.28 + Type site, 5.29 + List<Type> argtypes, 5.30 + List<Type> typeargtypes, boolean reportErrors) { 5.31 + Symbol sym = methodNotFound; 5.32 + JCDiagnostic explanation = null; 5.33 + List<MethodResolutionPhase> steps = methodResolutionSteps; 5.34 + while (steps.nonEmpty() && 5.35 + steps.head.isApplicable(boxingEnabled, varargsEnabled) && 5.36 + sym.kind >= ERRONEOUS) { 5.37 + sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, 5.38 + steps.head.isBoxingRequired(), 5.39 + env.info.varArgs = steps.head.isVarargsRequired()); 5.40 + methodResolutionCache.put(steps.head, sym); 5.41 + if (sym.kind == WRONG_MTH && 5.42 + ((InapplicableSymbolError)sym).explanation != null) { 5.43 + //if the symbol is an inapplicable method symbol, then the 5.44 + //explanation contains the reason for which inference failed 5.45 + explanation = ((InapplicableSymbolError)sym).explanation; 5.46 + } 5.47 + steps = steps.tail; 5.48 + } 5.49 + if (sym.kind >= AMBIGUOUS && reportErrors) { 5.50 + String key = explanation == null ? 5.51 + "cant.apply.diamond" : 5.52 + "cant.apply.diamond.1"; 5.53 + log.error(pos, key, diags.fragment("diamond", site.tsym), explanation); 5.54 + } 5.55 + return sym; 5.56 + } 5.57 + 5.58 /** Resolve constructor. 5.59 * @param pos The position to use for error reporting. 5.60 * @param env The environment current at the constructor invocation.
6.1 --- a/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Apr 14 12:23:29 2010 +0100 6.2 +++ b/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Wed Apr 14 12:31:55 2010 +0100 6.3 @@ -131,6 +131,7 @@ 6.4 this.allowForeach = source.allowForeach(); 6.5 this.allowStaticImport = source.allowStaticImport(); 6.6 this.allowAnnotations = source.allowAnnotations(); 6.7 + this.allowDiamond = source.allowDiamond(); 6.8 this.allowTypeAnnotations = source.allowTypeAnnotations(); 6.9 this.keepDocComments = keepDocComments; 6.10 if (keepDocComments) 6.11 @@ -148,6 +149,10 @@ 6.12 */ 6.13 boolean allowGenerics; 6.14 6.15 + /** Switch: Should diamond operator be recognized? 6.16 + */ 6.17 + boolean allowDiamond; 6.18 + 6.19 /** Switch: Should varargs be recognized? 6.20 */ 6.21 boolean allowVarargs; 6.22 @@ -190,10 +195,11 @@ 6.23 * mode = NOPARAMS : no parameters allowed for type 6.24 * mode = TYPEARG : type argument 6.25 */ 6.26 - static final int EXPR = 1; 6.27 - static final int TYPE = 2; 6.28 - static final int NOPARAMS = 4; 6.29 - static final int TYPEARG = 8; 6.30 + static final int EXPR = 0x1; 6.31 + static final int TYPE = 0x2; 6.32 + static final int NOPARAMS = 0x4; 6.33 + static final int TYPEARG = 0x8; 6.34 + static final int DIAMOND = 0x10; 6.35 6.36 /** The current mode. 6.37 */ 6.38 @@ -1343,6 +1349,11 @@ 6.39 ListBuffer<JCExpression> args = lb(); 6.40 if (S.token() == LT) { 6.41 S.nextToken(); 6.42 + if (S.token() == GT && (mode & DIAMOND) != 0) { 6.43 + checkDiamond(); 6.44 + S.nextToken(); 6.45 + return List.nil(); 6.46 + } 6.47 args.append(((mode & EXPR) == 0) ? typeArgument() : parseType()); 6.48 while (S.token() == COMMA) { 6.49 S.nextToken(); 6.50 @@ -1516,7 +1527,7 @@ 6.51 t = F.AnnotatedType(newAnnotations, t); 6.52 6.53 int oldmode = mode; 6.54 - mode = TYPE; 6.55 + mode = TYPE | DIAMOND; 6.56 if (S.token() == LT) { 6.57 checkGenerics(); 6.58 t = typeArguments(t); 6.59 @@ -1569,8 +1580,11 @@ 6.60 JCExpression innerCreator(int newpos, List<JCExpression> typeArgs, JCExpression encl) { 6.61 JCExpression t = toP(F.at(S.pos()).Ident(ident())); 6.62 if (S.token() == LT) { 6.63 + int oldmode = mode; 6.64 + mode |= DIAMOND; 6.65 checkGenerics(); 6.66 t = typeArguments(t); 6.67 + mode = oldmode; 6.68 } 6.69 return classCreatorRest(newpos, encl, typeArgs, t); 6.70 } 6.71 @@ -3173,4 +3187,10 @@ 6.72 allowTypeAnnotations = true; 6.73 } 6.74 } 6.75 + void checkDiamond() { 6.76 + if (!allowDiamond) { 6.77 + log.error(S.pos(), "diamond.not.supported.in.source", source.name); 6.78 + allowDiamond = true; 6.79 + } 6.80 + } 6.81 }
7.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Apr 14 12:23:29 2010 +0100 7.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Wed Apr 14 12:31:55 2010 +0100 7.3 @@ -479,6 +479,11 @@ 7.4 type parameters of {0} cannot be determined; {1} 7.5 compiler.err.invalid.inferred.types=\ 7.6 invalid inferred types for {0}; {1} 7.7 +compiler.err.cant.apply.diamond=\ 7.8 + cannot infer type arguments for {0} 7.9 +compiler.err.cant.apply.diamond.1=\ 7.10 + cannot infer type arguments for {0};\n\ 7.11 + reason: {1} 7.12 compiler.err.unreachable.stmt=\ 7.13 unreachable statement 7.14 compiler.err.initializer.must.be.able.to.complete.normally=\ 7.15 @@ -1030,7 +1035,12 @@ 7.16 actual arguments do not conform to inferred formal arguments\n\ 7.17 required: {0}\n\ 7.18 found: {1} 7.19 - 7.20 +compiler.misc.diamond=\ 7.21 + {0}<> 7.22 +compiler.misc.diamond.invalid.arg=\ 7.23 + type argument {0} inferred for {1} is not allowed in this context 7.24 +compiler.misc.diamond.invalid.args=\ 7.25 + type arguments {0} inferred for {1} are not allowed in this context 7.26 ##### 7.27 7.28 ## The first argument ({0}) is a "kindname". 7.29 @@ -1163,6 +1173,8 @@ 7.30 {0} in {1} implements {2} in {3} 7.31 compiler.misc.varargs.clash.with=\ 7.32 {0} in {1} overrides {2} in {3} 7.33 +compiler.misc.non.denotable.type=\ 7.34 + Non-denotable type {0} not allowed here 7.35 7.36 ######################################## 7.37 # Diagnostics for language feature changes
8.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Apr 14 12:23:29 2010 +0100 8.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Wed Apr 14 12:31:55 2010 +0100 8.3 @@ -204,6 +204,15 @@ 8.4 return (JCMethodInvocation)exec.expr; 8.5 } 8.6 8.7 + /** Return true if a tree represents a diamond new expr. */ 8.8 + public static boolean isDiamond(JCTree tree) { 8.9 + switch(tree.getTag()) { 8.10 + case JCTree.TYPEAPPLY: return ((JCTypeApply)tree).getTypeArguments().isEmpty(); 8.11 + case JCTree.NEWCLASS: return isDiamond(((JCNewClass)tree).clazz); 8.12 + default: return false; 8.13 + } 8.14 + } 8.15 + 8.16 /** Return true if a tree represents the null literal. */ 8.17 public static boolean isNull(JCTree tree) { 8.18 if (tree.getTag() != JCTree.LITERAL)
9.1 --- a/test/tools/javac/6840059/T6840059.out Wed Apr 14 12:23:29 2010 +0100 9.2 +++ b/test/tools/javac/6840059/T6840059.out Wed Apr 14 12:31:55 2010 +0100 9.3 @@ -1,3 +1,3 @@ 9.4 -T6840059.java:15:9: compiler.err.cant.resolve.location.args: kindname.constructor, T6840059, , java.lang.String, kindname.class, T6840059 9.5 -T6840059.java:15:25: compiler.err.cant.resolve.location.args: kindname.constructor, T6840059, , , kindname.class, T6840059 9.6 +T6840059.java:15:9: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, java.lang.String, kindname.class, T6840059, null 9.7 +T6840059.java:15:25: compiler.err.cant.apply.symbol: kindname.constructor, T6840059, java.lang.Integer, compiler.misc.no.args, kindname.class, T6840059, null 9.8 2 errors
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/tools/javac/generics/diamond/neg/Neg01.java Wed Apr 14 12:31:55 2010 +0100 10.3 @@ -0,0 +1,38 @@ 10.4 +/* 10.5 + * @test /nodynamiccopyright/ 10.6 + * @bug 6939620 10.7 + * 10.8 + * @summary Switch to 'complex' diamond inference scheme 10.9 + * @author mcimadamore 10.10 + * @compile/fail/ref=Neg01.out Neg01.java -XDrawDiagnostics 10.11 + * 10.12 + */ 10.13 + 10.14 +class Neg01<X extends Number> { 10.15 + 10.16 + Neg01(X x) {} 10.17 + 10.18 + <Z> Neg01(X x, Z z) {} 10.19 + 10.20 + void test() { 10.21 + Neg01<String> n1 = new Neg01<>(""); 10.22 + Neg01<? extends String> n2 = new Neg01<>(""); 10.23 + Neg01<?> n3 = new Neg01<>(""); 10.24 + Neg01<? super String> n4 = new Neg01<>(""); 10.25 + 10.26 + Neg01<String> n5 = new Neg01<>(""){}; 10.27 + Neg01<? extends String> n6 = new Neg01<>(""){}; 10.28 + Neg01<?> n7 = new Neg01<>(""){}; 10.29 + Neg01<? super String> n8 = new Neg01<>(""){}; 10.30 + 10.31 + Neg01<String> n9 = new Neg01<>("", ""); 10.32 + Neg01<? extends String> n10 = new Neg01<>("", ""); 10.33 + Neg01<?> n11 = new Neg01<>("", ""); 10.34 + Foo<? super String> n12 = new Neg01<>("", ""); 10.35 + 10.36 + Neg01<String> n13 = new Neg01<>("", ""){}; 10.37 + Neg01<? extends String> n14 = new Neg01<>("", ""){}; 10.38 + Neg01<?> n15 = new Neg01<>("", ""){}; 10.39 + Neg01<? super String> n16 = new Neg01<>("", ""){}; 10.40 + } 10.41 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/tools/javac/generics/diamond/neg/Neg01.out Wed Apr 14 12:31:55 2010 +0100 11.3 @@ -0,0 +1,29 @@ 11.4 +Neg01.java:18:15: compiler.err.not.within.bounds: java.lang.String 11.5 +Neg01.java:18:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.6 +Neg01.java:19:15: compiler.err.not.within.bounds: ? extends java.lang.String 11.7 +Neg01.java:19:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.8 +Neg01.java:20:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.9 +Neg01.java:21:15: compiler.err.not.within.bounds: ? super java.lang.String 11.10 +Neg01.java:21:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.11 +Neg01.java:23:15: compiler.err.not.within.bounds: java.lang.String 11.12 +Neg01.java:23:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.13 +Neg01.java:24:15: compiler.err.not.within.bounds: ? extends java.lang.String 11.14 +Neg01.java:24:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.15 +Neg01.java:25:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.16 +Neg01.java:26:15: compiler.err.not.within.bounds: ? super java.lang.String 11.17 +Neg01.java:26:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.18 +Neg01.java:28:15: compiler.err.not.within.bounds: java.lang.String 11.19 +Neg01.java:28:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.20 +Neg01.java:29:15: compiler.err.not.within.bounds: ? extends java.lang.String 11.21 +Neg01.java:29:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.22 +Neg01.java:30:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.23 +Neg01.java:31:9: compiler.err.cant.resolve.location: kindname.class, Foo, , , kindname.class, Neg01<X> 11.24 +Neg01.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.25 +Neg01.java:33:15: compiler.err.not.within.bounds: java.lang.String 11.26 +Neg01.java:33:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.27 +Neg01.java:34:15: compiler.err.not.within.bounds: ? extends java.lang.String 11.28 +Neg01.java:34:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.29 +Neg01.java:35:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.30 +Neg01.java:36:15: compiler.err.not.within.bounds: ? super java.lang.String 11.31 +Neg01.java:36:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg01), null 11.32 +28 errors
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/generics/diamond/neg/Neg02.java Wed Apr 14 12:31:55 2010 +0100 12.3 @@ -0,0 +1,61 @@ 12.4 +/* 12.5 + * @test /nodynamiccopyright/ 12.6 + * @bug 6939620 12.7 + * 12.8 + * @summary Switch to 'complex' diamond inference scheme 12.9 + * @author mcimadamore 12.10 + * @compile/fail/ref=Neg02.out Neg02.java -XDrawDiagnostics 12.11 + * 12.12 + */ 12.13 + 12.14 +class Neg02 { 12.15 + 12.16 + static class Foo<X extends Number> { 12.17 + Foo(X x) {} 12.18 + <Z> Foo(X x, Z z) {} 12.19 + } 12.20 + 12.21 + void testSimple() { 12.22 + Foo<String> f1 = new Foo<>(""); 12.23 + Foo<? extends String> f2 = new Foo<>(""); 12.24 + Foo<?> f3 = new Foo<>(""); 12.25 + Foo<? super String> f4 = new Foo<>(""); 12.26 + 12.27 + Foo<String> f5 = new Foo<>(""){}; 12.28 + Foo<? extends String> f6 = new Foo<>(""){}; 12.29 + Foo<?> f7 = new Foo<>(""){}; 12.30 + Foo<? super String> f8 = new Foo<>(""){}; 12.31 + 12.32 + Foo<String> f9 = new Foo<>("", ""); 12.33 + Foo<? extends String> f10 = new Foo<>("", ""); 12.34 + Foo<?> f11 = new Foo<>("", ""); 12.35 + Foo<? super String> f12 = new Foo<>("", ""); 12.36 + 12.37 + Foo<String> f13 = new Foo<>("", ""){}; 12.38 + Foo<? extends String> f14 = new Foo<>("", ""){}; 12.39 + Foo<?> f15 = new Foo<>("", ""){}; 12.40 + Foo<? super String> f16 = new Foo<>("", ""){}; 12.41 + } 12.42 + 12.43 + void testQualified() { 12.44 + Foo<String> f1 = new Neg02.Foo<>(""); 12.45 + Foo<? extends String> f2 = new Neg02.Foo<>(""); 12.46 + Foo<?> f3 = new Neg02.Foo<>(""); 12.47 + Foo<? super String> f4 = new Neg02.Foo<>(""); 12.48 + 12.49 + Foo<String> f5 = new Neg02.Foo<>(""){}; 12.50 + Foo<? extends String> f6 = new Neg02.Foo<>(""){}; 12.51 + Foo<?> f7 = new Neg02.Foo<>(""){}; 12.52 + Foo<? super String> f8 = new Neg02.Foo<>(""){}; 12.53 + 12.54 + Foo<String> f9 = new Neg02.Foo<>("", ""); 12.55 + Foo<? extends String> f10 = new Neg02.Foo<>("", ""); 12.56 + Foo<?> f11 = new Neg02.Foo<>("", ""); 12.57 + Foo<? super String> f12 = new Neg02.Foo<>("", ""); 12.58 + 12.59 + Foo<String> f13 = new Neg02.Foo<>("", ""){}; 12.60 + Foo<? extends String> f14 = new Neg02.Foo<>("", ""){}; 12.61 + Foo<?> f15 = new Neg02.Foo<>("", ""){}; 12.62 + Foo<? super String> f16 = new Neg02.Foo<>("", ""){}; 12.63 + } 12.64 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/tools/javac/generics/diamond/neg/Neg02.out Wed Apr 14 12:31:55 2010 +0100 13.3 @@ -0,0 +1,57 @@ 13.4 +Neg02.java:19:13: compiler.err.not.within.bounds: java.lang.String 13.5 +Neg02.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.6 +Neg02.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String 13.7 +Neg02.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.8 +Neg02.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.9 +Neg02.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String 13.10 +Neg02.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.11 +Neg02.java:24:13: compiler.err.not.within.bounds: java.lang.String 13.12 +Neg02.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.13 +Neg02.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String 13.14 +Neg02.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.15 +Neg02.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.16 +Neg02.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String 13.17 +Neg02.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.18 +Neg02.java:29:13: compiler.err.not.within.bounds: java.lang.String 13.19 +Neg02.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.20 +Neg02.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String 13.21 +Neg02.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.22 +Neg02.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.23 +Neg02.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String 13.24 +Neg02.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.25 +Neg02.java:34:13: compiler.err.not.within.bounds: java.lang.String 13.26 +Neg02.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.27 +Neg02.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String 13.28 +Neg02.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.29 +Neg02.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.30 +Neg02.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String 13.31 +Neg02.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.32 +Neg02.java:41:13: compiler.err.not.within.bounds: java.lang.String 13.33 +Neg02.java:41:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.34 +Neg02.java:42:13: compiler.err.not.within.bounds: ? extends java.lang.String 13.35 +Neg02.java:42:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.36 +Neg02.java:43:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.37 +Neg02.java:44:13: compiler.err.not.within.bounds: ? super java.lang.String 13.38 +Neg02.java:44:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.39 +Neg02.java:46:13: compiler.err.not.within.bounds: java.lang.String 13.40 +Neg02.java:46:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.41 +Neg02.java:47:13: compiler.err.not.within.bounds: ? extends java.lang.String 13.42 +Neg02.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.43 +Neg02.java:48:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.44 +Neg02.java:49:13: compiler.err.not.within.bounds: ? super java.lang.String 13.45 +Neg02.java:49:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.46 +Neg02.java:51:13: compiler.err.not.within.bounds: java.lang.String 13.47 +Neg02.java:51:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.48 +Neg02.java:52:13: compiler.err.not.within.bounds: ? extends java.lang.String 13.49 +Neg02.java:52:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.50 +Neg02.java:53:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.51 +Neg02.java:54:13: compiler.err.not.within.bounds: ? super java.lang.String 13.52 +Neg02.java:54:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.53 +Neg02.java:56:13: compiler.err.not.within.bounds: java.lang.String 13.54 +Neg02.java:56:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.55 +Neg02.java:57:13: compiler.err.not.within.bounds: ? extends java.lang.String 13.56 +Neg02.java:57:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.57 +Neg02.java:58:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.58 +Neg02.java:59:13: compiler.err.not.within.bounds: ? super java.lang.String 13.59 +Neg02.java:59:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg02.Foo), null 13.60 +56 errors
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/tools/javac/generics/diamond/neg/Neg03.java Wed Apr 14 12:31:55 2010 +0100 14.3 @@ -0,0 +1,83 @@ 14.4 +/* 14.5 + * @test /nodynamiccopyright/ 14.6 + * @bug 6939620 14.7 + * 14.8 + * @summary Switch to 'complex' diamond inference scheme 14.9 + * @author mcimadamore 14.10 + * @compile/fail/ref=Neg03.out Neg03.java -XDrawDiagnostics 14.11 + * 14.12 + */ 14.13 + 14.14 +class Neg03<U> { 14.15 + 14.16 + class Foo<V extends Number> { 14.17 + Foo(V x) {} 14.18 + <Z> Foo(V x, Z z) {} 14.19 + } 14.20 + 14.21 + void testSimple() { 14.22 + Foo<String> f1 = new Foo<>(""); 14.23 + Foo<? extends String> f2 = new Foo<>(""); 14.24 + Foo<?> f3 = new Foo<>(""); 14.25 + Foo<? super String> f4 = new Foo<>(""); 14.26 + 14.27 + Foo<String> f5 = new Foo<>(""){}; 14.28 + Foo<? extends String> f6 = new Foo<>(""){}; 14.29 + Foo<?> f7 = new Foo<>(""){}; 14.30 + Foo<? super String> f8 = new Foo<>(""){}; 14.31 + 14.32 + Foo<String> f9 = new Foo<>("", ""); 14.33 + Foo<? extends String> f10 = new Foo<>("", ""); 14.34 + Foo<?> f11 = new Foo<>("", ""); 14.35 + Foo<? super String> f12 = new Foo<>("", ""); 14.36 + 14.37 + Foo<String> f13 = new Foo<>("", ""){}; 14.38 + Foo<? extends String> f14 = new Foo<>("", ""){}; 14.39 + Foo<?> f15 = new Foo<>("", ""){}; 14.40 + Foo<? super String> f16 = new Foo<>("", ""){}; 14.41 + } 14.42 + 14.43 + void testQualified_1() { 14.44 + Foo<String> f1 = new Neg03<U>.Foo<>(""); 14.45 + Foo<? extends String> f2 = new Neg03<U>.Foo<>(""); 14.46 + Foo<?> f3 = new Neg03<U>.Foo<>(""); 14.47 + Foo<? super String> f4 = new Neg03<U>.Foo<>(""); 14.48 + 14.49 + Foo<String> f5 = new Neg03<U>.Foo<>(""){}; 14.50 + Foo<? extends String> f6 = new Neg03<U>.Foo<>(""){}; 14.51 + Foo<?> f7 = new Neg03<U>.Foo<>(""){}; 14.52 + Foo<? super String> f8 = new Neg03<U>.Foo<>(""){}; 14.53 + 14.54 + Foo<String> f9 = new Neg03<U>.Foo<>("", ""); 14.55 + Foo<? extends String> f10 = new Neg03<U>.Foo<>("", ""); 14.56 + Foo<?> f11 = new Neg03<U>.Foo<>("", ""); 14.57 + Foo<? super String> f12 = new Neg03<U>.Foo<>("", ""); 14.58 + 14.59 + Foo<String> f13 = new Neg03<U>.Foo<>("", ""){}; 14.60 + Foo<? extends String> f14 = new Neg03<U>.Foo<>("", ""){}; 14.61 + Foo<?> f15 = new Neg03<U>.Foo<>("", ""){}; 14.62 + Foo<? super String> f16 = new Neg03<U>.Foo<>("", ""){}; 14.63 + } 14.64 + 14.65 + void testQualified_2(Neg03<U> n) { 14.66 + Foo<String> f1 = n.new Foo<>(""); 14.67 + Foo<? extends String> f2 = n.new Foo<>(""); 14.68 + Foo<?> f3 = n.new Foo<>(""); 14.69 + Foo<? super String> f4 = n.new Foo<>(""); 14.70 + 14.71 + Foo<String> f5 = n.new Foo<>(""){}; 14.72 + Foo<? extends String> f6 = n.new Foo<>(""){}; 14.73 + Foo<?> f7 = n.new Foo<>(""){}; 14.74 + Foo<? super String> f8 = n.new Foo<>(""){}; 14.75 + 14.76 + Foo<String> f9 = n.new Foo<>("", ""); 14.77 + Foo<? extends String> f10 = n.new Foo<>("", ""); 14.78 + Foo<?> f11 = n.new Foo<>("", ""); 14.79 + Foo<? super String> f12 = n.new Foo<>("", ""); 14.80 + 14.81 + Foo<String> f13 = n.new Foo<>("", ""){}; 14.82 + Foo<? extends String> f14 = n.new Foo<>("", ""){}; 14.83 + Foo<?> f15 = n.new Foo<>("", ""){}; 14.84 + Foo<? super String> f16 = n.new Foo<>("", ""){}; 14.85 + } 14.86 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test/tools/javac/generics/diamond/neg/Neg03.out Wed Apr 14 12:31:55 2010 +0100 15.3 @@ -0,0 +1,85 @@ 15.4 +Neg03.java:19:13: compiler.err.not.within.bounds: java.lang.String 15.5 +Neg03.java:19:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.6 +Neg03.java:20:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.7 +Neg03.java:20:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.8 +Neg03.java:21:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.9 +Neg03.java:22:13: compiler.err.not.within.bounds: ? super java.lang.String 15.10 +Neg03.java:22:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.11 +Neg03.java:24:13: compiler.err.not.within.bounds: java.lang.String 15.12 +Neg03.java:24:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.13 +Neg03.java:25:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.14 +Neg03.java:25:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.15 +Neg03.java:26:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.16 +Neg03.java:27:13: compiler.err.not.within.bounds: ? super java.lang.String 15.17 +Neg03.java:27:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.18 +Neg03.java:29:13: compiler.err.not.within.bounds: java.lang.String 15.19 +Neg03.java:29:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.20 +Neg03.java:30:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.21 +Neg03.java:30:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.22 +Neg03.java:31:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.23 +Neg03.java:32:13: compiler.err.not.within.bounds: ? super java.lang.String 15.24 +Neg03.java:32:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.25 +Neg03.java:34:13: compiler.err.not.within.bounds: java.lang.String 15.26 +Neg03.java:34:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.27 +Neg03.java:35:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.28 +Neg03.java:35:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.29 +Neg03.java:36:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.30 +Neg03.java:37:13: compiler.err.not.within.bounds: ? super java.lang.String 15.31 +Neg03.java:37:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.32 +Neg03.java:41:13: compiler.err.not.within.bounds: java.lang.String 15.33 +Neg03.java:41:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.34 +Neg03.java:42:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.35 +Neg03.java:42:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.36 +Neg03.java:43:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.37 +Neg03.java:44:13: compiler.err.not.within.bounds: ? super java.lang.String 15.38 +Neg03.java:44:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.39 +Neg03.java:46:13: compiler.err.not.within.bounds: java.lang.String 15.40 +Neg03.java:46:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.41 +Neg03.java:47:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.42 +Neg03.java:47:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.43 +Neg03.java:48:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.44 +Neg03.java:49:13: compiler.err.not.within.bounds: ? super java.lang.String 15.45 +Neg03.java:49:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.46 +Neg03.java:51:13: compiler.err.not.within.bounds: java.lang.String 15.47 +Neg03.java:51:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.48 +Neg03.java:52:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.49 +Neg03.java:52:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.50 +Neg03.java:53:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.51 +Neg03.java:54:13: compiler.err.not.within.bounds: ? super java.lang.String 15.52 +Neg03.java:54:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.53 +Neg03.java:56:13: compiler.err.not.within.bounds: java.lang.String 15.54 +Neg03.java:56:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.55 +Neg03.java:57:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.56 +Neg03.java:57:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.57 +Neg03.java:58:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.58 +Neg03.java:59:13: compiler.err.not.within.bounds: ? super java.lang.String 15.59 +Neg03.java:59:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.60 +Neg03.java:63:13: compiler.err.not.within.bounds: java.lang.String 15.61 +Neg03.java:63:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.62 +Neg03.java:64:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.63 +Neg03.java:64:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.64 +Neg03.java:65:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.65 +Neg03.java:66:13: compiler.err.not.within.bounds: ? super java.lang.String 15.66 +Neg03.java:66:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.67 +Neg03.java:68:13: compiler.err.not.within.bounds: java.lang.String 15.68 +Neg03.java:68:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.69 +Neg03.java:69:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.70 +Neg03.java:69:38: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.71 +Neg03.java:70:23: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.72 +Neg03.java:71:13: compiler.err.not.within.bounds: ? super java.lang.String 15.73 +Neg03.java:71:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.74 +Neg03.java:73:13: compiler.err.not.within.bounds: java.lang.String 15.75 +Neg03.java:73:28: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.76 +Neg03.java:74:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.77 +Neg03.java:74:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.78 +Neg03.java:75:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.79 +Neg03.java:76:13: compiler.err.not.within.bounds: ? super java.lang.String 15.80 +Neg03.java:76:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.81 +Neg03.java:78:13: compiler.err.not.within.bounds: java.lang.String 15.82 +Neg03.java:78:29: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.83 +Neg03.java:79:13: compiler.err.not.within.bounds: ? extends java.lang.String 15.84 +Neg03.java:79:39: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.85 +Neg03.java:80:24: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.86 +Neg03.java:81:13: compiler.err.not.within.bounds: ? super java.lang.String 15.87 +Neg03.java:81:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Neg03.Foo), null 15.88 +84 errors
16.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 16.2 +++ b/test/tools/javac/generics/diamond/neg/Neg04.java Wed Apr 14 12:31:55 2010 +0100 16.3 @@ -0,0 +1,38 @@ 16.4 +/* 16.5 + * @test /nodynamiccopyright/ 16.6 + * @bug 6939620 16.7 + * 16.8 + * @summary Switch to 'complex' diamond inference scheme 16.9 + * @author mcimadamore 16.10 + * @compile/fail/ref=Neg04.out Neg04.java -XDrawDiagnostics 16.11 + * 16.12 + */ 16.13 + 16.14 +class Neg04 { 16.15 + 16.16 + void test() { 16.17 + class Foo<V extends Number> { 16.18 + Foo(V x) {} 16.19 + <Z> Foo(V x, Z z) {} 16.20 + } 16.21 + Foo<String> n1 = new Foo<>(""); 16.22 + Foo<? extends String> n2 = new Foo<>(""); 16.23 + Foo<?> n3 = new Foo<>(""); 16.24 + Foo<? super String> n4 = new Foo<>(""); 16.25 + 16.26 + Foo<String> n5 = new Foo<>(""){}; 16.27 + Foo<? extends String> n6 = new Foo<>(""){}; 16.28 + Foo<?> n7 = new Foo<>(""){}; 16.29 + Foo<? super String> n8 = new Foo<>(""){}; 16.30 + 16.31 + Foo<String> n9 = new Foo<>("", ""); 16.32 + Foo<? extends String> n10 = new Foo<>("", ""); 16.33 + Foo<?> n11 = new Foo<>("", ""); 16.34 + Foo<? super String> n12 = new Foo<>("", ""); 16.35 + 16.36 + Foo<String> n13 = new Foo<>("", ""){}; 16.37 + Foo<? extends String> n14 = new Foo<>("", ""){}; 16.38 + Foo<?> n15 = new Foo<>("", ""){}; 16.39 + Foo<? super String> n16 = new Foo<>("", ""){}; 16.40 + } 16.41 +}
17.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 17.2 +++ b/test/tools/javac/generics/diamond/neg/Neg04.out Wed Apr 14 12:31:55 2010 +0100 17.3 @@ -0,0 +1,29 @@ 17.4 +Neg04.java:18:13: compiler.err.not.within.bounds: java.lang.String 17.5 +Neg04.java:18:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.6 +Neg04.java:19:13: compiler.err.not.within.bounds: ? extends java.lang.String 17.7 +Neg04.java:19:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.8 +Neg04.java:20:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.9 +Neg04.java:21:13: compiler.err.not.within.bounds: ? super java.lang.String 17.10 +Neg04.java:21:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.11 +Neg04.java:23:13: compiler.err.not.within.bounds: java.lang.String 17.12 +Neg04.java:23:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.13 +Neg04.java:24:13: compiler.err.not.within.bounds: ? extends java.lang.String 17.14 +Neg04.java:24:36: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.15 +Neg04.java:25:21: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.16 +Neg04.java:26:13: compiler.err.not.within.bounds: ? super java.lang.String 17.17 +Neg04.java:26:34: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.18 +Neg04.java:28:13: compiler.err.not.within.bounds: java.lang.String 17.19 +Neg04.java:28:26: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.20 +Neg04.java:29:13: compiler.err.not.within.bounds: ? extends java.lang.String 17.21 +Neg04.java:29:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.22 +Neg04.java:30:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.23 +Neg04.java:31:13: compiler.err.not.within.bounds: ? super java.lang.String 17.24 +Neg04.java:31:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.25 +Neg04.java:33:13: compiler.err.not.within.bounds: java.lang.String 17.26 +Neg04.java:33:27: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.27 +Neg04.java:34:13: compiler.err.not.within.bounds: ? extends java.lang.String 17.28 +Neg04.java:34:37: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.29 +Neg04.java:35:22: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.30 +Neg04.java:36:13: compiler.err.not.within.bounds: ? super java.lang.String 17.31 +Neg04.java:36:35: compiler.err.cant.apply.diamond: (compiler.misc.diamond: Foo), null 17.32 +28 errors
18.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 18.2 +++ b/test/tools/javac/generics/diamond/neg/Neg05.java Wed Apr 14 12:31:55 2010 +0100 18.3 @@ -0,0 +1,61 @@ 18.4 +/* 18.5 + * @test /nodynamiccopyright/ 18.6 + * @bug 6939620 18.7 + * 18.8 + * @summary Switch to 'complex' diamond inference scheme 18.9 + * @author mcimadamore 18.10 + * @compile/fail/ref=Neg05.out Neg05.java -XDrawDiagnostics 18.11 + * 18.12 + */ 18.13 + 18.14 +class Neg05<U> { 18.15 + 18.16 + class Foo<V> { 18.17 + Foo(V x) {} 18.18 + <Z> Foo(V x, Z z) {} 18.19 + } 18.20 + 18.21 + void testRare_1() { 18.22 + Neg05<?>.Foo<String> f1 = new Neg05.Foo<>(""); 18.23 + Neg05<?>.Foo<? extends String> f2 = new Neg05.Foo<>(""); 18.24 + Neg05<?>.Foo<?> f3 = new Neg05.Foo<>(""); 18.25 + Neg05<?>.Foo<? super String> f4 = new Neg05.Foo<>(""); 18.26 + 18.27 + Neg05<?>.Foo<String> f5 = new Neg05.Foo<>(""){}; 18.28 + Neg05<?>.Foo<? extends String> f6 = new Neg05.Foo<>(""){}; 18.29 + Neg05<?>.Foo<?> f7 = new Neg05.Foo<>(""){}; 18.30 + Neg05<?>.Foo<? super String> f8 = new Neg05.Foo<>(""){}; 18.31 + 18.32 + Neg05<?>.Foo<String> f9 = new Neg05.Foo<>("", ""); 18.33 + Neg05<?>.Foo<? extends String> f10 = new Neg05.Foo<>("", ""); 18.34 + Neg05<?>.Foo<?> f11 = new Neg05.Foo<>("", ""); 18.35 + Neg05<?>.Foo<? super String> f12 = new Neg05.Foo<>("", ""); 18.36 + 18.37 + Neg05<?>.Foo<String> f13 = new Neg05.Foo<>("", ""){}; 18.38 + Neg05<?>.Foo<? extends String> f14 = new Neg05.Foo<>("", ""){}; 18.39 + Neg05<?>.Foo<?> f15 = new Neg05.Foo<>("", ""){}; 18.40 + Neg05<?>.Foo<? super String> f16 = new Neg05.Foo<>("", ""){}; 18.41 + } 18.42 + 18.43 + void testRare_2(Neg05 n) { 18.44 + Neg05<?>.Foo<String> f1 = n.new Foo<>(""); 18.45 + Neg05<?>.Foo<? extends String> f2 = n.new Foo<>(""); 18.46 + Neg05<?>.Foo<?> f3 = n.new Foo<>(""); 18.47 + Neg05<?>.Foo<? super String> f4 = n.new Foo<>(""); 18.48 + 18.49 + Neg05<?>.Foo<String> f5 = n.new Foo<>(""){}; 18.50 + Neg05<?>.Foo<? extends String> f6 = n.new Foo<>(""){}; 18.51 + Neg05<?>.Foo<?> f7 = n.new Foo<>(""){}; 18.52 + Neg05<?>.Foo<? super String> f8 = n.new Foo<>(""){}; 18.53 + 18.54 + Neg05<?>.Foo<String> f9 = n.new Foo<>("", ""); 18.55 + Neg05<?>.Foo<? extends String> f10 = n.new Foo<>("", ""); 18.56 + Neg05<?>.Foo<?> f11 = n.new Foo<>("", ""); 18.57 + Neg05<?>.Foo<? super String> f12 = n.new Foo<>("", ""); 18.58 + 18.59 + Neg05<?>.Foo<String> f13 = n.new Foo<>("", ""){}; 18.60 + Neg05<?>.Foo<? extends String> f14 = n.new Foo<>("", ""){}; 18.61 + Neg05<?>.Foo<?> f15 = n.new Foo<>("", ""){}; 18.62 + Neg05<?>.Foo<? super String> f16 = n.new Foo<>("", ""){}; 18.63 + } 18.64 +}
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/test/tools/javac/generics/diamond/neg/Neg05.out Wed Apr 14 12:31:55 2010 +0100 19.3 @@ -0,0 +1,49 @@ 19.4 +Neg05.java:19:48: compiler.err.improperly.formed.type.inner.raw.param 19.5 +Neg05.java:19:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String> 19.6 +Neg05.java:20:58: compiler.err.improperly.formed.type.inner.raw.param 19.7 +Neg05.java:20:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String> 19.8 +Neg05.java:21:43: compiler.err.improperly.formed.type.inner.raw.param 19.9 +Neg05.java:21:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?> 19.10 +Neg05.java:22:56: compiler.err.improperly.formed.type.inner.raw.param 19.11 +Neg05.java:22:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String> 19.12 +Neg05.java:24:48: compiler.err.improperly.formed.type.inner.raw.param 19.13 +Neg05.java:24:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String> 19.14 +Neg05.java:25:58: compiler.err.improperly.formed.type.inner.raw.param 19.15 +Neg05.java:25:45: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String> 19.16 +Neg05.java:26:43: compiler.err.improperly.formed.type.inner.raw.param 19.17 +Neg05.java:26:30: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?> 19.18 +Neg05.java:27:56: compiler.err.improperly.formed.type.inner.raw.param 19.19 +Neg05.java:27:43: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String> 19.20 +Neg05.java:29:48: compiler.err.improperly.formed.type.inner.raw.param 19.21 +Neg05.java:29:35: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String> 19.22 +Neg05.java:30:59: compiler.err.improperly.formed.type.inner.raw.param 19.23 +Neg05.java:30:46: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String> 19.24 +Neg05.java:31:44: compiler.err.improperly.formed.type.inner.raw.param 19.25 +Neg05.java:31:31: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?> 19.26 +Neg05.java:32:57: compiler.err.improperly.formed.type.inner.raw.param 19.27 +Neg05.java:32:44: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String> 19.28 +Neg05.java:34:49: compiler.err.improperly.formed.type.inner.raw.param 19.29 +Neg05.java:34:36: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<java.lang.String> 19.30 +Neg05.java:35:59: compiler.err.improperly.formed.type.inner.raw.param 19.31 +Neg05.java:35:46: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? extends java.lang.String> 19.32 +Neg05.java:36:44: compiler.err.improperly.formed.type.inner.raw.param 19.33 +Neg05.java:36:31: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<?> 19.34 +Neg05.java:37:57: compiler.err.improperly.formed.type.inner.raw.param 19.35 +Neg05.java:37:44: compiler.err.prob.found.req: (compiler.misc.incompatible.types), compiler.misc.anonymous.class: Neg05.Foo<java.lang.String>, Neg05<?>.Foo<? super java.lang.String> 19.36 +Neg05.java:41:37: compiler.err.improperly.formed.type.inner.raw.param 19.37 +Neg05.java:42:47: compiler.err.improperly.formed.type.inner.raw.param 19.38 +Neg05.java:43:32: compiler.err.improperly.formed.type.inner.raw.param 19.39 +Neg05.java:44:45: compiler.err.improperly.formed.type.inner.raw.param 19.40 +Neg05.java:46:37: compiler.err.improperly.formed.type.inner.raw.param 19.41 +Neg05.java:47:47: compiler.err.improperly.formed.type.inner.raw.param 19.42 +Neg05.java:48:32: compiler.err.improperly.formed.type.inner.raw.param 19.43 +Neg05.java:49:45: compiler.err.improperly.formed.type.inner.raw.param 19.44 +Neg05.java:51:37: compiler.err.improperly.formed.type.inner.raw.param 19.45 +Neg05.java:52:48: compiler.err.improperly.formed.type.inner.raw.param 19.46 +Neg05.java:53:33: compiler.err.improperly.formed.type.inner.raw.param 19.47 +Neg05.java:54:46: compiler.err.improperly.formed.type.inner.raw.param 19.48 +Neg05.java:56:38: compiler.err.improperly.formed.type.inner.raw.param 19.49 +Neg05.java:57:48: compiler.err.improperly.formed.type.inner.raw.param 19.50 +Neg05.java:58:33: compiler.err.improperly.formed.type.inner.raw.param 19.51 +Neg05.java:59:46: compiler.err.improperly.formed.type.inner.raw.param 19.52 +48 errors
20.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 20.2 +++ b/test/tools/javac/generics/diamond/neg/Neg06.java Wed Apr 14 12:31:55 2010 +0100 20.3 @@ -0,0 +1,21 @@ 20.4 +/* 20.5 + * @test /nodynamiccopyright/ 20.6 + * @bug 6939620 20.7 + * 20.8 + * @summary Switch to 'complex' diamond inference scheme 20.9 + * @author mcimadamore 20.10 + * @compile/fail/ref=Neg06.out Neg06.java -XDrawDiagnostics 20.11 + * 20.12 + */ 20.13 + 20.14 +class Neg06 { 20.15 + interface ISuperFoo<X> {} 20.16 + interface IFoo<X extends Number> extends ISuperFoo<X> {} 20.17 + 20.18 + static class CSuperFoo<X> {} 20.19 + static class CFoo<X extends Number> extends CSuperFoo<X> {} 20.20 + 20.21 + ISuperFoo<String> isf = new IFoo<>() {}; 20.22 + CSuperFoo<String> csf1 = new CFoo<>(); 20.23 + CSuperFoo<String> csf2 = new CFoo<>() {}; 20.24 +}
21.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 21.2 +++ b/test/tools/javac/generics/diamond/neg/Neg06.out Wed Apr 14 12:31:55 2010 +0100 21.3 @@ -0,0 +1,4 @@ 21.4 +Neg06.java:18:36: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.IFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.IFoo<X>, Neg06.ISuperFoo<java.lang.String>) 21.5 +Neg06.java:19:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>) 21.6 +Neg06.java:20:37: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg06.CFoo), (compiler.misc.no.conforming.instance.exists: X, Neg06.CFoo<X>, Neg06.CSuperFoo<java.lang.String>) 21.7 +3 errors
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/test/tools/javac/generics/diamond/neg/Neg07.java Wed Apr 14 12:31:55 2010 +0100 22.3 @@ -0,0 +1,19 @@ 22.4 +/* 22.5 + * @test /nodynamiccopyright/ 22.6 + * @bug 6939620 22.7 + * 22.8 + * @summary Switch to 'complex' diamond inference scheme 22.9 + * @author mcimadamore 22.10 + * @compile/fail/ref=Neg07.out Neg07.java -XDrawDiagnostics 22.11 + * 22.12 + */ 22.13 + 22.14 +class Neg07 { 22.15 + static class SuperFoo<X> {} 22.16 + static class Foo<X extends Number> extends SuperFoo<X> { 22.17 + Foo(X x) {} 22.18 + } 22.19 + 22.20 + SuperFoo<String> sf1 = new Foo<>(""); 22.21 + SuperFoo<String> sf2 = new Foo<>("") {}; 22.22 +}
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23.2 +++ b/test/tools/javac/generics/diamond/neg/Neg07.out Wed Apr 14 12:31:55 2010 +0100 23.3 @@ -0,0 +1,3 @@ 23.4 +Neg07.java:17:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number) 23.5 +Neg07.java:18:27: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg07.Foo), (compiler.misc.inferred.do.not.conform.to.bounds: java.lang.String, java.lang.Number) 23.6 +2 errors
24.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 24.2 +++ b/test/tools/javac/generics/diamond/neg/Neg08.java Wed Apr 14 12:31:55 2010 +0100 24.3 @@ -0,0 +1,30 @@ 24.4 +/* 24.5 + * @test /nodynamiccopyright/ 24.6 + * @bug 6939620 6894753 24.7 + * 24.8 + * @summary Switch to 'complex' diamond inference scheme 24.9 + * @author mcimadamore 24.10 + * @compile/fail/ref=Neg08.out Neg08.java -XDrawDiagnostics 24.11 + * 24.12 + */ 24.13 + 24.14 +class Neg08 { 24.15 + static class Foo<X> { 24.16 + Foo(X x) { } 24.17 + } 24.18 + 24.19 + static class DoubleFoo<X,Y> { 24.20 + DoubleFoo(X x,Y y) { } 24.21 + } 24.22 + 24.23 + static class TripleFoo<X,Y,Z> { 24.24 + TripleFoo(X x,Y y,Z z) { } 24.25 + } 24.26 + 24.27 + Foo<? extends Integer> fi = new Foo<>(1); 24.28 + Foo<?> fw = new Foo<>(fi); 24.29 + Foo<? extends Double> fd = new Foo<>(3.0); 24.30 + DoubleFoo<?,?> dw = new DoubleFoo<>(fi,fd); 24.31 + Foo<String> fs = new Foo<>("one"); 24.32 + TripleFoo<?,?,?> tw = new TripleFoo<>(fi,fd,fs); 24.33 +}
25.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 25.2 +++ b/test/tools/javac/generics/diamond/neg/Neg08.out Wed Apr 14 12:31:55 2010 +0100 25.3 @@ -0,0 +1,4 @@ 25.4 +Neg08.java:25:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.Foo), (compiler.misc.diamond.invalid.arg: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>, (compiler.misc.diamond: Neg08.Foo)) 25.5 +Neg08.java:27:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.DoubleFoo), (compiler.misc.diamond.invalid.args: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg08.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg08.DoubleFoo)) 25.6 +Neg08.java:29:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg08.TripleFoo), (compiler.misc.diamond.invalid.args: Neg08.Foo<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>,Neg08.Foo<compiler.misc.type.captureof: 2, ? extends java.lang.Double>, (compiler.misc.diamond: Neg08.TripleFoo)) 25.7 +3 errors
26.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 26.2 +++ b/test/tools/javac/generics/diamond/neg/Neg09.java Wed Apr 14 12:31:55 2010 +0100 26.3 @@ -0,0 +1,22 @@ 26.4 +/* 26.5 + * @test /nodynamiccopyright/ 26.6 + * @bug 6939620 6894753 26.7 + * 26.8 + * @summary Switch to 'complex' diamond inference scheme 26.9 + * @author mcimadamore 26.10 + * @compile/fail/ref=Neg09.out Neg09.java -XDrawDiagnostics 26.11 + * 26.12 + */ 26.13 + 26.14 +class Neg09 { 26.15 + static class Foo<X extends Number & Comparable<Number>> {} 26.16 + static class DoubleFoo<X extends Number & Comparable<Number>, 26.17 + Y extends Number & Comparable<Number>> {} 26.18 + static class TripleFoo<X extends Number & Comparable<Number>, 26.19 + Y extends Number & Comparable<Number>, 26.20 + Z> {} 26.21 + 26.22 + Foo<?> fw = new Foo<>(); 26.23 + DoubleFoo<?,?> dw = new DoubleFoo<>(); 26.24 + TripleFoo<?,?,?> tw = new TripleFoo<>(); 26.25 +}
27.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 27.2 +++ b/test/tools/javac/generics/diamond/neg/Neg09.out Wed Apr 14 12:31:55 2010 +0100 27.3 @@ -0,0 +1,4 @@ 27.4 +Neg09.java:19:24: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.Foo), (compiler.misc.diamond.invalid.arg: java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.Foo)) 27.5 +Neg09.java:20:38: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.DoubleFoo), (compiler.misc.diamond.invalid.args: java.lang.Number&java.lang.Comparable<java.lang.Number>,java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.DoubleFoo)) 27.6 +Neg09.java:21:40: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg09.TripleFoo), (compiler.misc.diamond.invalid.args: java.lang.Number&java.lang.Comparable<java.lang.Number>,java.lang.Number&java.lang.Comparable<java.lang.Number>, (compiler.misc.diamond: Neg09.TripleFoo)) 27.7 +3 errors
28.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 28.2 +++ b/test/tools/javac/generics/diamond/neg/Neg10.java Wed Apr 14 12:31:55 2010 +0100 28.3 @@ -0,0 +1,17 @@ 28.4 +/* 28.5 + * @test /nodynamiccopyright/ 28.6 + * @bug 6939620 28.7 + * 28.8 + * @summary Switch to 'complex' diamond inference scheme 28.9 + * @author mcimadamore 28.10 + * @compile/fail/ref=Neg10.out Neg10.java -XDrawDiagnostics 28.11 + * 28.12 + */ 28.13 + 28.14 +class Neg10 { 28.15 + static class Foo<X> { 28.16 + Foo(X x) {} 28.17 + } 28.18 + 28.19 + Foo<Number> fw = new Foo<>(1); 28.20 +}
29.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 29.2 +++ b/test/tools/javac/generics/diamond/neg/Neg10.out Wed Apr 14 12:31:55 2010 +0100 29.3 @@ -0,0 +1,2 @@ 29.4 +Neg10.java:16:22: compiler.err.prob.found.req: (compiler.misc.incompatible.types), Neg10.Foo<java.lang.Integer>, Neg10.Foo<java.lang.Number> 29.5 +1 error
30.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 30.2 +++ b/test/tools/javac/generics/diamond/neg/Neg11.java Wed Apr 14 12:31:55 2010 +0100 30.3 @@ -0,0 +1,18 @@ 30.4 +/* 30.5 + * @test /nodynamiccopyright/ 30.6 + * @bug 6939620 30.7 + * 30.8 + * @summary Switch to 'complex' diamond inference scheme 30.9 + * @author mcimadamore 30.10 + * @compile/fail/ref=Neg11.out Neg11.java -XDrawDiagnostics 30.11 + * 30.12 + */ 30.13 + 30.14 +class Neg11 { 30.15 + 30.16 + void test() { 30.17 + class Foo<X extends Number> { } 30.18 + Foo<?> f1 = new UndeclaredName<>(); //this is deliberate: aim is to test erroneous path 30.19 + Foo<?> f2 = new UndeclaredName<>() {}; //this is deliberate: aim is to test erroneous path 30.20 + } 30.21 +}
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/test/tools/javac/generics/diamond/neg/Neg11.out Wed Apr 14 12:31:55 2010 +0100 31.3 @@ -0,0 +1,3 @@ 31.4 +Neg11.java:15:25: compiler.err.cant.resolve.location: kindname.class, UndeclaredName, , , kindname.class, Neg11 31.5 +Neg11.java:16:25: compiler.err.cant.resolve.location: kindname.class, UndeclaredName, , , kindname.class, Neg11 31.6 +2 errors
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 32.2 +++ b/test/tools/javac/generics/diamond/pos/Pos01.java Wed Apr 14 12:31:55 2010 +0100 32.3 @@ -0,0 +1,67 @@ 32.4 +/* 32.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 32.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 32.7 + * 32.8 + * This code is free software; you can redistribute it and/or modify it 32.9 + * under the terms of the GNU General Public License version 2 only, as 32.10 + * published by the Free Software Foundation. 32.11 + * 32.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 32.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 32.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 32.15 + * version 2 for more details (a copy is included in the LICENSE file that 32.16 + * accompanied this code). 32.17 + * 32.18 + * You should have received a copy of the GNU General Public License version 32.19 + * 2 along with this work; if not, write to the Free Software Foundation, 32.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 32.21 + * 32.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 32.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 32.24 + * have any questions. 32.25 + */ 32.26 + 32.27 +/* 32.28 + * @test 32.29 + * @bug 6939620 32.30 + * 32.31 + * @summary Switch to 'complex' diamond inference scheme 32.32 + * @author mcimadamore 32.33 + * @compile Pos01.java 32.34 + * @run main Pos01 32.35 + * 32.36 + */ 32.37 + 32.38 +public class Pos01<X> { 32.39 + 32.40 + Pos01(X x) {} 32.41 + 32.42 + <Z> Pos01(X x, Z z) {} 32.43 + 32.44 + void test() { 32.45 + Pos01<Integer> p1 = new Pos01<>(1); 32.46 + Pos01<? extends Integer> p2 = new Pos01<>(1); 32.47 + Pos01<?> p3 = new Pos01<>(1); 32.48 + Pos01<? super Integer> p4 = new Pos01<>(1); 32.49 + 32.50 + Pos01<Integer> p5 = new Pos01<>(1){}; 32.51 + Pos01<? extends Integer> p6 = new Pos01<>(1){}; 32.52 + Pos01<?> p7 = new Pos01<>(1){}; 32.53 + Pos01<? super Integer> p8 = new Pos01<>(1){}; 32.54 + 32.55 + Pos01<Integer> p9 = new Pos01<>(1, ""); 32.56 + Pos01<? extends Integer> p10 = new Pos01<>(1, ""); 32.57 + Pos01<?> p11 = new Pos01<>(1, ""); 32.58 + Pos01<? super Integer> p12 = new Pos01<>(1, ""); 32.59 + 32.60 + Pos01<Integer> p13 = new Pos01<>(1, ""){}; 32.61 + Pos01<? extends Integer> p14= new Pos01<>(1, ""){}; 32.62 + Pos01<?> p15 = new Pos01<>(1, ""){}; 32.63 + Pos01<? super Integer> p16 = new Pos01<>(1, ""){}; 32.64 + } 32.65 + 32.66 + public static void main(String[] args) { 32.67 + Pos01<String> p1 = new Pos01<>(""); 32.68 + p1.test(); 32.69 + } 32.70 +}
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 33.2 +++ b/test/tools/javac/generics/diamond/pos/Pos02.java Wed Apr 14 12:31:55 2010 +0100 33.3 @@ -0,0 +1,90 @@ 33.4 +/* 33.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 33.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 33.7 + * 33.8 + * This code is free software; you can redistribute it and/or modify it 33.9 + * under the terms of the GNU General Public License version 2 only, as 33.10 + * published by the Free Software Foundation. 33.11 + * 33.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 33.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 33.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 33.15 + * version 2 for more details (a copy is included in the LICENSE file that 33.16 + * accompanied this code). 33.17 + * 33.18 + * You should have received a copy of the GNU General Public License version 33.19 + * 2 along with this work; if not, write to the Free Software Foundation, 33.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 33.21 + * 33.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 33.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 33.24 + * have any questions. 33.25 + */ 33.26 + 33.27 +/* 33.28 + * @test 33.29 + * @bug 6939620 33.30 + * 33.31 + * @summary Switch to 'complex' diamond inference scheme 33.32 + * @author mcimadamore 33.33 + * @compile Pos02.java 33.34 + * @run main Pos02 33.35 + */ 33.36 + 33.37 +public class Pos02 { 33.38 + 33.39 + static class Foo<X> { 33.40 + Foo(X x) {} 33.41 + <Z> Foo(X x, Z z) {} 33.42 + } 33.43 + 33.44 + void testSimple() { 33.45 + Foo<Integer> f1 = new Foo<>(1); 33.46 + Foo<? extends Integer> f2 = new Foo<>(1); 33.47 + Foo<?> f3 = new Foo<>(1); 33.48 + Foo<? super Integer> f4 = new Foo<>(1); 33.49 + 33.50 + Foo<Integer> f5 = new Foo<>(1){}; 33.51 + Foo<? extends Integer> f6 = new Foo<>(1){}; 33.52 + Foo<?> f7 = new Foo<>(1){}; 33.53 + Foo<? super Integer> f8 = new Foo<>(1){}; 33.54 + 33.55 + Foo<Integer> f9 = new Foo<>(1, ""); 33.56 + Foo<? extends Integer> f10 = new Foo<>(1, ""); 33.57 + Foo<?> f11 = new Foo<>(1, ""); 33.58 + Foo<? super Integer> f12 = new Foo<>(1, ""); 33.59 + 33.60 + Foo<Integer> f13 = new Foo<>(1, ""){}; 33.61 + Foo<? extends Integer> f14 = new Foo<>(1, ""){}; 33.62 + Foo<?> f15 = new Foo<>(1, ""){}; 33.63 + Foo<? super Integer> f16 = new Foo<>(1, ""){}; 33.64 + } 33.65 + 33.66 + void testQualified() { 33.67 + Foo<Integer> f1 = new Pos02.Foo<>(1); 33.68 + Foo<? extends Integer> f2 = new Pos02.Foo<>(1); 33.69 + Foo<?> f3 = new Pos02.Foo<>(1); 33.70 + Foo<? super Integer> f4 = new Pos02.Foo<>(1); 33.71 + 33.72 + Foo<Integer> f5 = new Pos02.Foo<>(1){}; 33.73 + Foo<? extends Integer> f6 = new Pos02.Foo<>(1){}; 33.74 + Foo<?> f7 = new Pos02.Foo<>(1){}; 33.75 + Foo<? super Integer> f8 = new Pos02.Foo<>(1){}; 33.76 + 33.77 + Foo<Integer> f9 = new Pos02.Foo<>(1, ""); 33.78 + Foo<? extends Integer> f10 = new Pos02.Foo<>(1, ""); 33.79 + Foo<?> f11 = new Pos02.Foo<>(1, ""); 33.80 + Foo<? super Integer> f12 = new Pos02.Foo<>(1, ""); 33.81 + 33.82 + Foo<Integer> f13 = new Pos02.Foo<>(1, ""){}; 33.83 + Foo<? extends Integer> f14 = new Pos02.Foo<>(1, ""){}; 33.84 + Foo<?> f15 = new Pos02.Foo<>(1, ""){}; 33.85 + Foo<? super Integer> f16 = new Pos02.Foo<>(1, ""){}; 33.86 + } 33.87 + 33.88 + public static void main(String[] args) { 33.89 + Pos02 p2 = new Pos02(); 33.90 + p2.testSimple(); 33.91 + p2.testQualified(); 33.92 + } 33.93 +}
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 34.2 +++ b/test/tools/javac/generics/diamond/pos/Pos03.java Wed Apr 14 12:31:55 2010 +0100 34.3 @@ -0,0 +1,114 @@ 34.4 +/* 34.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 34.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 34.7 + * 34.8 + * This code is free software; you can redistribute it and/or modify it 34.9 + * under the terms of the GNU General Public License version 2 only, as 34.10 + * published by the Free Software Foundation. 34.11 + * 34.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 34.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 34.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 34.15 + * version 2 for more details (a copy is included in the LICENSE file that 34.16 + * accompanied this code). 34.17 + * 34.18 + * You should have received a copy of the GNU General Public License version 34.19 + * 2 along with this work; if not, write to the Free Software Foundation, 34.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 34.21 + * 34.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 34.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 34.24 + * have any questions. 34.25 + */ 34.26 + 34.27 +/* 34.28 + * @test 34.29 + * @bug 6939620 34.30 + * 34.31 + * @summary Switch to 'complex' diamond inference scheme 34.32 + * @author mcimadamore 34.33 + * @compile Pos03.java 34.34 + * @run main Pos03 34.35 + * 34.36 + */ 34.37 + 34.38 +public class Pos03<U> { 34.39 + 34.40 + class Foo<V> { 34.41 + Foo(V x) {} 34.42 + <Z> Foo(V x, Z z) {} 34.43 + } 34.44 + 34.45 + void testSimple() { 34.46 + Foo<Integer> f1 = new Foo<>(1); 34.47 + Foo<? extends Integer> f2 = new Foo<>(1); 34.48 + Foo<?> f3 = new Foo<>(1); 34.49 + Foo<? super Integer> f4 = new Foo<>(1); 34.50 + 34.51 + Foo<Integer> f5 = new Foo<>(1){}; 34.52 + Foo<? extends Integer> f6 = new Foo<>(1){}; 34.53 + Foo<?> f7 = new Foo<>(1){}; 34.54 + Foo<? super Integer> f8 = new Foo<>(1){}; 34.55 + 34.56 + Foo<Integer> f9 = new Foo<>(1, ""); 34.57 + Foo<? extends Integer> f10 = new Foo<>(1, ""); 34.58 + Foo<?> f11 = new Foo<>(1, ""); 34.59 + Foo<? super Integer> f12 = new Foo<>(1, ""); 34.60 + 34.61 + Foo<Integer> f13 = new Foo<>(1, ""){}; 34.62 + Foo<? extends Integer> f14 = new Foo<>(1, ""){}; 34.63 + Foo<?> f15 = new Foo<>(1, ""){}; 34.64 + Foo<? super Integer> f16 = new Foo<>(1, ""){}; 34.65 + } 34.66 + 34.67 + void testQualified_1() { 34.68 + Foo<Integer> f1 = new Pos03<U>.Foo<>(1); 34.69 + Foo<? extends Integer> f2 = new Pos03<U>.Foo<>(1); 34.70 + Foo<?> f3 = new Pos03<U>.Foo<>(1); 34.71 + Foo<? super Integer> f4 = new Pos03<U>.Foo<>(1); 34.72 + 34.73 + Foo<Integer> f5 = new Pos03<U>.Foo<>(1){}; 34.74 + Foo<? extends Integer> f6 = new Pos03<U>.Foo<>(1){}; 34.75 + Foo<?> f7 = new Pos03<U>.Foo<>(1){}; 34.76 + Foo<? super Integer> f8 = new Pos03<U>.Foo<>(1){}; 34.77 + 34.78 + Foo<Integer> f9 = new Pos03<U>.Foo<>(1, ""); 34.79 + Foo<? extends Integer> f10 = new Pos03<U>.Foo<>(1, ""); 34.80 + Foo<?> f11 = new Pos03<U>.Foo<>(1, ""); 34.81 + Foo<? super Integer> f12 = new Pos03<U>.Foo<>(1, ""); 34.82 + 34.83 + Foo<Integer> f13 = new Pos03<U>.Foo<>(1, ""){}; 34.84 + Foo<? extends Integer> f14 = new Pos03<U>.Foo<>(1, ""){}; 34.85 + Foo<?> f15 = new Pos03<U>.Foo<>(1, ""){}; 34.86 + Foo<? super Integer> f16 = new Pos03<U>.Foo<>(1, ""){}; 34.87 + } 34.88 + 34.89 + void testQualified_2(Pos03<U> p) { 34.90 + Foo<Integer> f1 = p.new Foo<>(1); 34.91 + Foo<? extends Integer> f2 = p.new Foo<>(1); 34.92 + Foo<?> f3 = p.new Foo<>(1); 34.93 + Foo<? super Integer> f4 = p.new Foo<>(1); 34.94 + 34.95 + Foo<Integer> f5 = p.new Foo<>(1){}; 34.96 + Foo<? extends Integer> f6 = p.new Foo<>(1){}; 34.97 + Foo<?> f7 = p.new Foo<>(1){}; 34.98 + Foo<? super Integer> f8 = p.new Foo<>(1){}; 34.99 + 34.100 + Foo<Integer> f9 = p.new Foo<>(1, ""); 34.101 + Foo<? extends Integer> f10 = p.new Foo<>(1, ""); 34.102 + Foo<?> f11 = p.new Foo<>(1, ""); 34.103 + Foo<? super Integer> f12 = p.new Foo<>(1, ""); 34.104 + 34.105 + Foo<Integer> f13 = p.new Foo<>(1, ""){}; 34.106 + Foo<? extends Integer> f14 = p.new Foo<>(1, ""){}; 34.107 + Foo<?> f15 = p.new Foo<>(1, ""){}; 34.108 + Foo<? super Integer> f16 = p.new Foo<>(1, ""){}; 34.109 + } 34.110 + 34.111 + public static void main(String[] args) { 34.112 + Pos03<String> p3 = new Pos03<>(); 34.113 + p3.testSimple(); 34.114 + p3.testQualified_1(); 34.115 + p3.testQualified_2(p3); 34.116 + } 34.117 +}
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 35.2 +++ b/test/tools/javac/generics/diamond/pos/Pos04.java Wed Apr 14 12:31:55 2010 +0100 35.3 @@ -0,0 +1,67 @@ 35.4 +/* 35.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 35.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 35.7 + * 35.8 + * This code is free software; you can redistribute it and/or modify it 35.9 + * under the terms of the GNU General Public License version 2 only, as 35.10 + * published by the Free Software Foundation. 35.11 + * 35.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 35.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 35.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 35.15 + * version 2 for more details (a copy is included in the LICENSE file that 35.16 + * accompanied this code). 35.17 + * 35.18 + * You should have received a copy of the GNU General Public License version 35.19 + * 2 along with this work; if not, write to the Free Software Foundation, 35.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 35.21 + * 35.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 35.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 35.24 + * have any questions. 35.25 + */ 35.26 + 35.27 +/* 35.28 + * @test 35.29 + * @bug 6939620 35.30 + * 35.31 + * @summary Switch to 'complex' diamond inference scheme 35.32 + * @author mcimadamore 35.33 + * @compile Pos04.java 35.34 + * @run main Pos04 35.35 + * 35.36 + */ 35.37 + 35.38 +public class Pos04<U> { 35.39 + 35.40 + void test() { 35.41 + class Foo<V> { 35.42 + Foo(V x) {} 35.43 + <Z> Foo(V x, Z z) {} 35.44 + } 35.45 + Foo<Integer> p1 = new Foo<>(1); 35.46 + Foo<? extends Integer> p2 = new Foo<>(1); 35.47 + Foo<?> p3 = new Foo<>(1); 35.48 + Foo<? super Integer> p4 = new Foo<>(1); 35.49 + 35.50 + Foo<Integer> p5 = new Foo<>(1){}; 35.51 + Foo<? extends Integer> p6 = new Foo<>(1){}; 35.52 + Foo<?> p7 = new Foo<>(1){}; 35.53 + Foo<? super Integer> p8 = new Foo<>(1){}; 35.54 + 35.55 + Foo<Integer> p9 = new Foo<>(1, ""); 35.56 + Foo<? extends Integer> p10 = new Foo<>(1, ""); 35.57 + Foo<?> p11 = new Foo<>(1, ""); 35.58 + Foo<? super Integer> p12 = new Foo<>(1, ""); 35.59 + 35.60 + Foo<Integer> p13 = new Foo<>(1, ""){}; 35.61 + Foo<? extends Integer> p14 = new Foo<>(1, ""){}; 35.62 + Foo<?> p15 = new Foo<>(1, ""){}; 35.63 + Foo<? super Integer> p16 = new Foo<>(1, ""){}; 35.64 + } 35.65 + 35.66 + public static void main(String[] args) { 35.67 + Pos04<String> p4 = new Pos04<>(); 35.68 + p4.test(); 35.69 + } 35.70 +}
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 36.2 +++ b/test/tools/javac/generics/diamond/pos/Pos05.java Wed Apr 14 12:31:55 2010 +0100 36.3 @@ -0,0 +1,45 @@ 36.4 +/* 36.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 36.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 36.7 + * 36.8 + * This code is free software; you can redistribute it and/or modify it 36.9 + * under the terms of the GNU General Public License version 2 only, as 36.10 + * published by the Free Software Foundation. 36.11 + * 36.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 36.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 36.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 36.15 + * version 2 for more details (a copy is included in the LICENSE file that 36.16 + * accompanied this code). 36.17 + * 36.18 + * You should have received a copy of the GNU General Public License version 36.19 + * 2 along with this work; if not, write to the Free Software Foundation, 36.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 36.21 + * 36.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 36.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 36.24 + * have any questions. 36.25 + */ 36.26 + 36.27 +/* 36.28 + * @test 36.29 + * @bug 6939620 36.30 + * 36.31 + * @summary Switch to 'complex' diamond inference scheme 36.32 + * @author mcimadamore 36.33 + * @compile Pos05.java 36.34 + * 36.35 + */ 36.36 + 36.37 +public class Pos05 { 36.38 + 36.39 + static class Foo<X> { 36.40 + Foo(X x) {} 36.41 + } 36.42 + 36.43 + void m(Foo<Integer> fi) {} 36.44 + 36.45 + void test() { 36.46 + m(new Foo<>(1)); 36.47 + } 36.48 +}