Fri, 08 Jun 2012 12:45:43 -0700
Merge
test/tools/javac/diags/examples/FullInstSig.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/diags/examples/InvalidInferredTypes.java | file | annotate | diff | comparison | revisions | |
test/tools/javac/diags/examples/UndeterminedType1.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Type.java Thu Jun 07 12:10:41 2012 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Type.java Fri Jun 08 12:45:43 2012 -0700 1.3 @@ -54,7 +54,7 @@ 1.4 * package types (tag: PACKAGE, class: PackageType), 1.5 * type variables (tag: TYPEVAR, class: TypeVar), 1.6 * type arguments (tag: WILDCARD, class: WildcardType), 1.7 - * polymorphic types (tag: FORALL, class: ForAll), 1.8 + * generic method types (tag: FORALL, class: ForAll), 1.9 * the error type (tag: ERROR, class: ErrorType). 1.10 * </pre> 1.11 * 1.12 @@ -1108,11 +1108,16 @@ 1.13 public boolean isErroneous() { return qtype.isErroneous(); } 1.14 } 1.15 1.16 + /** 1.17 + * The type of a generic method type. It consists of a method type and 1.18 + * a list of method type-parameters that are used within the method 1.19 + * type. 1.20 + */ 1.21 public static class ForAll extends DelegatedType implements ExecutableType { 1.22 public List<Type> tvars; 1.23 1.24 public ForAll(List<Type> tvars, Type qtype) { 1.25 - super(FORALL, qtype); 1.26 + super(FORALL, (MethodType)qtype); 1.27 this.tvars = tvars; 1.28 } 1.29 1.30 @@ -1131,34 +1136,6 @@ 1.31 return qtype.isErroneous(); 1.32 } 1.33 1.34 - /** 1.35 - * Replaces this ForAll's typevars with a set of concrete Java types 1.36 - * and returns the instantiated generic type. Subclasses should override 1.37 - * in order to check that the list of types is a valid instantiation 1.38 - * of the ForAll's typevars. 1.39 - * 1.40 - * @param actuals list of actual types 1.41 - * @param types types instance 1.42 - * @return qtype where all occurrences of tvars are replaced 1.43 - * by types in actuals 1.44 - */ 1.45 - public Type inst(List<Type> actuals, Types types) { 1.46 - return types.subst(qtype, tvars, actuals); 1.47 - } 1.48 - 1.49 - /** 1.50 - * Get the type-constraints of a given kind for a given type-variable of 1.51 - * this ForAll type. Subclasses should override in order to return more 1.52 - * accurate sets of constraints. 1.53 - * 1.54 - * @param tv the type-variable for which the constraint is to be retrieved 1.55 - * @param ck the constraint kind to be retrieved 1.56 - * @return the list of types specified by the selected constraint 1.57 - */ 1.58 - public List<Type> undetvars() { 1.59 - return List.nil(); 1.60 - } 1.61 - 1.62 public Type map(Mapping f) { 1.63 return f.apply(qtype); 1.64 } 1.65 @@ -1168,7 +1145,7 @@ 1.66 } 1.67 1.68 public MethodType asMethodType() { 1.69 - return qtype.asMethodType(); 1.70 + return (MethodType)qtype; 1.71 } 1.72 1.73 public void complete() {
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Jun 07 12:10:41 2012 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Jun 08 12:45:43 2012 -0700 2.3 @@ -702,6 +702,13 @@ 2.4 return t; 2.5 } 2.6 2.7 + Type attribIdentAsEnumType(Env<AttrContext> env, JCIdent id) { 2.8 + Assert.check((env.enclClass.sym.flags() & ENUM) != 0); 2.9 + id.type = env.info.scope.owner.type; 2.10 + id.sym = env.info.scope.owner; 2.11 + return id.type; 2.12 + } 2.13 + 2.14 public void visitClassDef(JCClassDecl tree) { 2.15 // Local classes have not been entered yet, so we need to do it now: 2.16 if ((env.info.scope.owner.kind & (VAR | MTH)) != 0) 2.17 @@ -1529,7 +1536,7 @@ 2.18 2.19 // ...and check that it is legal in the current context. 2.20 // (this will also set the tree's type) 2.21 - Type mpt = newMethTemplate(argtypes, typeargtypes); 2.22 + Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes); 2.23 checkId(tree.meth, site, sym, localEnv, new ResultInfo(MTH, mpt), 2.24 tree.varargsElement != null); 2.25 } 2.26 @@ -1545,7 +1552,7 @@ 2.27 // ... and attribute the method using as a prototype a methodtype 2.28 // whose formal argument types is exactly the list of actual 2.29 // arguments (this will also set the method symbol). 2.30 - Type mpt = newMethTemplate(argtypes, typeargtypes); 2.31 + Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes); 2.32 localEnv.info.varArgs = false; 2.33 Type mtype = attribExpr(tree.meth, localEnv, mpt); 2.34 2.35 @@ -1608,8 +1615,8 @@ 2.36 2.37 /** Obtain a method type with given argument types. 2.38 */ 2.39 - Type newMethTemplate(List<Type> argtypes, List<Type> typeargtypes) { 2.40 - MethodType mt = new MethodType(argtypes, null, null, syms.methodClass); 2.41 + Type newMethodTemplate(Type restype, List<Type> argtypes, List<Type> typeargtypes) { 2.42 + MethodType mt = new MethodType(argtypes, restype, null, syms.methodClass); 2.43 return (typeargtypes == null) ? mt : (Type)new ForAll(typeargtypes, mt); 2.44 } 2.45 2.46 @@ -1657,7 +1664,10 @@ 2.47 2.48 // Attribute clazz expression and store 2.49 // symbol + type back into the attributed tree. 2.50 - Type clazztype = attribType(clazz, env); 2.51 + Type clazztype = TreeInfo.isEnumInit(env.tree) ? 2.52 + attribIdentAsEnumType(env, (JCIdent)clazz) : 2.53 + attribType(clazz, env); 2.54 + 2.55 clazztype = chk.checkDiamond(tree, clazztype); 2.56 chk.validate(clazz, localEnv); 2.57 if (tree.encl != null) { 2.58 @@ -1883,25 +1893,23 @@ 2.59 typeargtypes); 2.60 2.61 if (constructor.kind == MTH) { 2.62 - clazztype = checkMethod(site, 2.63 - constructor, 2.64 - localEnv, 2.65 - tree.args, 2.66 - argtypes, 2.67 - typeargtypes, 2.68 - localEnv.info.varArgs).getReturnType(); 2.69 - } else { 2.70 - clazztype = syms.errType; 2.71 - } 2.72 - 2.73 - if (clazztype.tag == FORALL && !resultInfo.pt.isErroneous()) { 2.74 try { 2.75 - clazztype = resultInfo.checkContext.rawInstantiatePoly((ForAll)clazztype, pt(), Warner.noWarnings); 2.76 - } catch (Infer.InferenceException ex) { 2.77 + clazztype = rawCheckMethod(site, 2.78 + constructor, 2.79 + resultInfo, 2.80 + localEnv, 2.81 + tree.args, 2.82 + argtypes, 2.83 + typeargtypes, 2.84 + localEnv.info.varArgs).getReturnType(); 2.85 + } catch (Resolve.InapplicableMethodException ex) { 2.86 //an error occurred while inferring uninstantiated type-variables 2.87 resultInfo.checkContext.report(tree.clazz.pos(), clazztype, resultInfo.pt, 2.88 diags.fragment("cant.apply.diamond.1", diags.fragment("diamond", clazztype.tsym), ex.diagnostic)); 2.89 + clazztype = syms.errType; 2.90 } 2.91 + } else { 2.92 + clazztype = syms.errType; 2.93 } 2.94 2.95 return chk.checkClassType(tree.clazz.pos(), clazztype, true); 2.96 @@ -2255,15 +2263,6 @@ 2.97 sitesym != null && 2.98 sitesym.name == names._super; 2.99 2.100 - // If selected expression is polymorphic, strip 2.101 - // type parameters and remember in env.info.tvars, so that 2.102 - // they can be added later (in Attr.checkId and Infer.instantiateMethod). 2.103 - if (tree.selected.type.tag == FORALL) { 2.104 - ForAll pstype = (ForAll)tree.selected.type; 2.105 - env.info.tvars = pstype.tvars; 2.106 - site = tree.selected.type = pstype.qtype; 2.107 - } 2.108 - 2.109 // Determine the symbol represented by the selection. 2.110 env.info.varArgs = false; 2.111 Symbol sym = selectSym(tree, sitesym, site, env, resultInfo); 2.112 @@ -2347,7 +2346,6 @@ 2.113 2.114 env.info.selectSuper = selectSuperPrev; 2.115 result = checkId(tree, site, sym, env, resultInfo, varArgs); 2.116 - env.info.tvars = List.nil(); 2.117 } 2.118 //where 2.119 /** Determine symbol referenced by a Select expression, 2.120 @@ -2530,16 +2528,6 @@ 2.121 ? types.memberType(site, sym) 2.122 : sym.type; 2.123 2.124 - if (env.info.tvars.nonEmpty()) { 2.125 - Type owntype1 = new ForAll(env.info.tvars, owntype); 2.126 - for (List<Type> l = env.info.tvars; l.nonEmpty(); l = l.tail) 2.127 - if (!owntype.contains(l.head)) { 2.128 - log.error(tree.pos(), "undetermined.type", owntype1); 2.129 - owntype1 = types.createErrorType(owntype1); 2.130 - } 2.131 - owntype = owntype1; 2.132 - } 2.133 - 2.134 // If the variable is a constant, record constant value in 2.135 // computed type. 2.136 if (v.getConstValue() != null && isStaticReference(tree)) 2.137 @@ -2551,9 +2539,10 @@ 2.138 break; 2.139 case MTH: { 2.140 JCMethodInvocation app = (JCMethodInvocation)env.tree; 2.141 - owntype = checkMethod(site, sym, env, app.args, 2.142 - resultInfo.pt.getParameterTypes(), resultInfo.pt.getTypeArguments(), 2.143 - env.info.varArgs); 2.144 + owntype = checkMethod(site, sym, 2.145 + new ResultInfo(VAL, resultInfo.pt.getReturnType(), resultInfo.checkContext), 2.146 + env, app.args, resultInfo.pt.getParameterTypes(), 2.147 + resultInfo.pt.getTypeArguments(), env.info.varArgs); 2.148 break; 2.149 } 2.150 case PCK: case ERR: 2.151 @@ -2692,6 +2681,33 @@ 2.152 **/ 2.153 public Type checkMethod(Type site, 2.154 Symbol sym, 2.155 + ResultInfo resultInfo, 2.156 + Env<AttrContext> env, 2.157 + final List<JCExpression> argtrees, 2.158 + List<Type> argtypes, 2.159 + List<Type> typeargtypes, 2.160 + boolean useVarargs) { 2.161 + try { 2.162 + return rawCheckMethod(site, sym, resultInfo, env, argtrees, argtypes, typeargtypes, useVarargs); 2.163 + } catch (Resolve.InapplicableMethodException ex) { 2.164 + String key = ex.getDiagnostic() == null ? 2.165 + "cant.apply.symbol" : 2.166 + "cant.apply.symbol.1"; 2.167 + log.error(env.tree.pos, key, 2.168 + Kinds.kindName(sym), 2.169 + sym.name == names.init ? sym.owner.name : sym.name, 2.170 + rs.methodArguments(sym.type.getParameterTypes()), 2.171 + rs.methodArguments(argtypes), 2.172 + Kinds.kindName(sym.owner), 2.173 + sym.owner.type, 2.174 + ex.getDiagnostic()); 2.175 + return types.createErrorType(site); 2.176 + } 2.177 + } 2.178 + 2.179 + private Type rawCheckMethod(Type site, 2.180 + Symbol sym, 2.181 + ResultInfo resultInfo, 2.182 Env<AttrContext> env, 2.183 final List<JCExpression> argtrees, 2.184 List<Type> argtypes, 2.185 @@ -2717,32 +2733,19 @@ 2.186 // Resolve.instantiate from the symbol's type as well as 2.187 // any type arguments and value arguments. 2.188 noteWarner.clear(); 2.189 - Type owntype = rs.instantiate(env, 2.190 - site, 2.191 - sym, 2.192 - argtypes, 2.193 - typeargtypes, 2.194 - true, 2.195 - useVarargs, 2.196 - noteWarner); 2.197 + Type owntype = rs.rawInstantiate(env, 2.198 + site, 2.199 + sym, 2.200 + resultInfo, 2.201 + argtypes, 2.202 + typeargtypes, 2.203 + true, 2.204 + useVarargs, 2.205 + noteWarner); 2.206 2.207 boolean unchecked = noteWarner.hasNonSilentLint(LintCategory.UNCHECKED); 2.208 2.209 - // If this fails, something went wrong; we should not have 2.210 - // found the identifier in the first place. 2.211 - if (owntype == null) { 2.212 - if (!pt().isErroneous()) 2.213 - log.error(env.tree.pos(), 2.214 - "internal.error.cant.instantiate", 2.215 - sym, site, 2.216 - Type.toString(pt().getParameterTypes())); 2.217 - owntype = types.createErrorType(site); 2.218 - return types.createErrorType(site); 2.219 - } else if (owntype.getReturnType().tag == FORALL && !unchecked) { 2.220 - return owntype; 2.221 - } else { 2.222 - return chk.checkMethod(owntype, sym, env, argtrees, argtypes, useVarargs, unchecked); 2.223 - } 2.224 + return chk.checkMethod(owntype, sym, env, argtrees, argtypes, useVarargs, unchecked); 2.225 } 2.226 2.227 /** 2.228 @@ -2755,7 +2758,7 @@ 2.229 List<Type> argtypes, 2.230 List<Type> typeargtypes, 2.231 boolean useVarargs) { 2.232 - Type owntype = checkMethod(site, sym, env, argtrees, argtypes, typeargtypes, useVarargs); 2.233 + Type owntype = checkMethod(site, sym, new ResultInfo(VAL, syms.voidType), env, argtrees, argtypes, typeargtypes, useVarargs); 2.234 chk.checkType(env.tree.pos(), owntype.getReturnType(), syms.voidType); 2.235 return owntype; 2.236 }
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/AttrContext.java Thu Jun 07 12:10:41 2012 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/AttrContext.java Fri Jun 08 12:45:43 2012 -0700 3.3 @@ -58,10 +58,6 @@ 3.4 */ 3.5 boolean varArgs = false; 3.6 3.7 - /** A list of type variables that are all-quantifed in current context. 3.8 - */ 3.9 - List<Type> tvars = List.nil(); 3.10 - 3.11 /** A record of the lint/SuppressWarnings currently in effect 3.12 */ 3.13 Lint lint; 3.14 @@ -80,7 +76,6 @@ 3.15 info.isSelfCall = isSelfCall; 3.16 info.selectSuper = selectSuper; 3.17 info.varArgs = varArgs; 3.18 - info.tvars = tvars; 3.19 info.lint = lint; 3.20 info.enclVar = enclVar; 3.21 return info;
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Jun 07 12:10:41 2012 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Jun 08 12:45:43 2012 -0700 4.3 @@ -424,10 +424,6 @@ 4.4 */ 4.5 boolean compatible(Type found, Type req, Warner warn); 4.6 /** 4.7 - * Instantiate a ForAll type against a given target type 'req' in given context 4.8 - */ 4.9 - Type rawInstantiatePoly(ForAll found, Type req, Warner warn); 4.10 - /** 4.11 * Report a check error 4.12 */ 4.13 void report(DiagnosticPosition pos, Type found, Type req, JCDiagnostic details); 4.14 @@ -454,10 +450,6 @@ 4.15 return enclosingContext.compatible(found, req, warn); 4.16 } 4.17 4.18 - public Type rawInstantiatePoly(ForAll found, Type req, Warner warn) { 4.19 - return enclosingContext.rawInstantiatePoly(found, req, warn); 4.20 - } 4.21 - 4.22 public void report(DiagnosticPosition pos, Type found, Type req, JCDiagnostic details) { 4.23 enclosingContext.report(pos, found, req, details); 4.24 } 4.25 @@ -482,12 +474,6 @@ 4.26 return types.isAssignable(found, req, warn); 4.27 } 4.28 4.29 - public Type rawInstantiatePoly(ForAll found, Type req, Warner warn) { 4.30 - if (req.tag == NONE) 4.31 - req = found.qtype.tag <= VOID ? found.qtype : syms.objectType; 4.32 - return infer.instantiateExpr(found, req, warn); 4.33 - } 4.34 - 4.35 public Warner checkWarner(DiagnosticPosition pos, Type found, Type req) { 4.36 return convertWarner(pos, found, req); 4.37 } 4.38 @@ -506,11 +492,6 @@ 4.39 Type checkType(final DiagnosticPosition pos, Type found, Type req, CheckContext checkContext) { 4.40 if (req.tag == ERROR) 4.41 return req; 4.42 - if (found.tag == FORALL) { 4.43 - ForAll fa = (ForAll)found; 4.44 - Type owntype = instantiatePoly(pos, checkContext, fa, req, checkContext.checkWarner(pos, found, req)); 4.45 - return checkType(pos, owntype, req, checkContext); 4.46 - } 4.47 if (req.tag == NONE) 4.48 return found; 4.49 if (checkContext.compatible(found, req, checkContext.checkWarner(pos, found, req))) { 4.50 @@ -525,32 +506,6 @@ 4.51 } 4.52 } 4.53 4.54 - /** Instantiate polymorphic type to some prototype, unless 4.55 - * prototype is `anyPoly' in which case polymorphic type 4.56 - * is returned unchanged. 4.57 - */ 4.58 - Type instantiatePoly(DiagnosticPosition pos, CheckContext checkContext, ForAll t, Type pt, Warner warn) throws Infer.NoInstanceException { 4.59 - try { 4.60 - return checkContext.rawInstantiatePoly(t, pt, warn); 4.61 - } catch (final Infer.NoInstanceException ex) { 4.62 - JCDiagnostic d = ex.getDiagnostic(); 4.63 - if (d != null) { 4.64 - if (ex.isAmbiguous) { 4.65 - d = diags.fragment("undetermined.type", t, d); 4.66 - } 4.67 - } 4.68 - checkContext.report(pos, t, pt, d); 4.69 - return types.createErrorType(pt); 4.70 - } catch (Infer.InvalidInstanceException ex) { 4.71 - JCDiagnostic d = ex.getDiagnostic(); 4.72 - if (d != null) { 4.73 - d = diags.fragment("invalid.inferred.types", t.tvars, d); 4.74 - } 4.75 - checkContext.report(pos, t, pt, d); 4.76 - return types.createErrorType(pt); 4.77 - } 4.78 - } 4.79 - 4.80 /** Check that a given type can be cast to a given target type. 4.81 * Return the result of the cast. 4.82 * @param pos Position to be used for error reporting. 4.83 @@ -561,10 +516,7 @@ 4.84 return checkCastable(pos, found, req, basicHandler); 4.85 } 4.86 Type checkCastable(DiagnosticPosition pos, Type found, Type req, CheckContext checkContext) { 4.87 - if (found.tag == FORALL) { 4.88 - instantiatePoly(pos, basicHandler, (ForAll) found, req, castWarner(pos, found, req)); 4.89 - return req; 4.90 - } else if (types.isCastable(found, req, castWarner(pos, found, req))) { 4.91 + if (types.isCastable(found, req, castWarner(pos, found, req))) { 4.92 return req; 4.93 } else { 4.94 checkContext.report(pos, found, req, diags.fragment("inconvertible.types", found, req));
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Thu Jun 07 12:10:41 2012 -0700 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Jun 08 12:45:43 2012 -0700 5.3 @@ -214,16 +214,23 @@ 5.4 * If no instantiation exists, or if several incomparable 5.5 * best instantiations exist throw a NoInstanceException. 5.6 */ 5.7 - public Type instantiateExpr(ForAll that, 5.8 - Type to, 5.9 + public List<Type> instantiateUninferred(DiagnosticPosition pos, 5.10 + List<Type> undetvars, 5.11 + List<Type> tvars, 5.12 + MethodType mtype, 5.13 + Attr.ResultInfo resultInfo, 5.14 Warner warn) throws InferenceException { 5.15 - List<Type> undetvars = that.undetvars(); 5.16 - Type qtype1 = types.subst(that.qtype, that.tvars, undetvars); 5.17 + Type to = resultInfo.pt; 5.18 + if (to.tag == NONE) { 5.19 + to = mtype.getReturnType().tag <= VOID ? 5.20 + mtype.getReturnType() : syms.objectType; 5.21 + } 5.22 + Type qtype1 = types.subst(mtype.getReturnType(), tvars, undetvars); 5.23 if (!types.isSubtype(qtype1, 5.24 qtype1.tag == UNDETVAR ? types.boxedTypeOrType(to) : to)) { 5.25 throw unambiguousNoInstanceException 5.26 .setMessage("infer.no.conforming.instance.exists", 5.27 - that.tvars, that.qtype, to); 5.28 + tvars, mtype.getReturnType(), to); 5.29 } 5.30 5.31 List<Type> insttypes; 5.32 @@ -232,32 +239,32 @@ 5.33 insttypes = List.nil(); 5.34 for (Type t : undetvars) { 5.35 UndetVar uv = (UndetVar)t; 5.36 - if (uv.inst == null && (uv.eq.nonEmpty() || !Type.containsAny(uv.hibounds, that.tvars))) { 5.37 + if (uv.inst == null && (uv.eq.nonEmpty() || !Type.containsAny(uv.hibounds, tvars))) { 5.38 maximizeInst((UndetVar)t, warn); 5.39 stuck = false; 5.40 } 5.41 insttypes = insttypes.append(uv.inst == null ? uv.qtype : uv.inst); 5.42 } 5.43 - if (!Type.containsAny(insttypes, that.tvars)) { 5.44 + if (!Type.containsAny(insttypes, tvars)) { 5.45 //all variables have been instantiated - exit 5.46 break; 5.47 } else if (stuck) { 5.48 //some variables could not be instantiated because of cycles in 5.49 //upper bounds - provide a (possibly recursive) default instantiation 5.50 insttypes = types.subst(insttypes, 5.51 - that.tvars, 5.52 - instantiateAsUninferredVars(undetvars, that.tvars)); 5.53 + tvars, 5.54 + instantiateAsUninferredVars(undetvars, tvars)); 5.55 break; 5.56 } else { 5.57 //some variables have been instantiated - replace newly instantiated 5.58 //variables in remaining upper bounds and continue 5.59 for (Type t : undetvars) { 5.60 UndetVar uv = (UndetVar)t; 5.61 - uv.hibounds = types.subst(uv.hibounds, that.tvars, insttypes); 5.62 + uv.hibounds = types.subst(uv.hibounds, tvars, insttypes); 5.63 } 5.64 } 5.65 } 5.66 - return that.inst(insttypes, types); 5.67 + return insttypes; 5.68 } 5.69 5.70 /** 5.71 @@ -296,18 +303,19 @@ 5.72 /** Instantiate method type `mt' by finding instantiations of 5.73 * `tvars' so that method can be applied to `argtypes'. 5.74 */ 5.75 - public Type instantiateMethod(final Env<AttrContext> env, 5.76 + public Type instantiateMethod(Env<AttrContext> env, 5.77 List<Type> tvars, 5.78 MethodType mt, 5.79 - final Symbol msym, 5.80 - final List<Type> argtypes, 5.81 - final boolean allowBoxing, 5.82 - final boolean useVarargs, 5.83 - final Warner warn) throws InferenceException { 5.84 + Attr.ResultInfo resultInfo, 5.85 + Symbol msym, 5.86 + List<Type> argtypes, 5.87 + boolean allowBoxing, 5.88 + boolean useVarargs, 5.89 + Warner warn) throws InferenceException { 5.90 //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG 5.91 - final List<Type> undetvars = makeUndetvars(tvars); 5.92 + List<Type> undetvars = makeUndetvars(tvars); 5.93 5.94 - final List<Type> capturedArgs = 5.95 + List<Type> capturedArgs = 5.96 rs.checkRawArgumentsAcceptable(env, undetvars, argtypes, mt.getParameterTypes(), 5.97 allowBoxing, useVarargs, warn, new InferenceCheckHandler(undetvars)); 5.98 5.99 @@ -344,38 +352,23 @@ 5.100 5.101 mt = (MethodType)types.subst(mt, tvars, insttypes.toList()); 5.102 5.103 - if (!restvars.isEmpty()) { 5.104 - // if there are uninstantiated variables, 5.105 - // quantify result type with them 5.106 - final List<Type> inferredTypes = insttypes.toList(); 5.107 - final List<Type> all_tvars = tvars; //this is the wrong tvars 5.108 - return new UninferredMethodType(env.tree.pos(), msym, mt, restvars.toList()) { 5.109 - @Override 5.110 - List<Type> undetvars() { 5.111 - return restundet.toList(); 5.112 - } 5.113 - @Override 5.114 - void instantiateReturnType(Type restype, List<Type> inferred, Types types) throws NoInstanceException { 5.115 - Type owntype = new MethodType(types.subst(getParameterTypes(), tvars, inferred), 5.116 - restype, 5.117 - types.subst(getThrownTypes(), tvars, inferred), 5.118 - qtype.tsym); 5.119 - // check that actuals conform to inferred formals 5.120 - warn.clear(); 5.121 - checkArgumentsAcceptable(env, capturedArgs, owntype.getParameterTypes(), allowBoxing, useVarargs, warn); 5.122 - // check that inferred bounds conform to their bounds 5.123 - checkWithinBounds(all_tvars, undetvars, 5.124 - types.subst(inferredTypes, tvars, inferred), warn); 5.125 - qtype = chk.checkMethod(owntype, msym, env, TreeInfo.args(env.tree), capturedArgs, useVarargs, warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)); 5.126 - } 5.127 - }; 5.128 + if (!restvars.isEmpty() && resultInfo != null) { 5.129 + List<Type> restInferred = 5.130 + instantiateUninferred(env.tree.pos(), restundet.toList(), restvars.toList(), mt, resultInfo, warn); 5.131 + checkWithinBounds(tvars, undetvars, 5.132 + types.subst(insttypes.toList(), restvars.toList(), restInferred), warn); 5.133 + mt = (MethodType)types.subst(mt, restvars.toList(), restInferred); 5.134 + if (rs.verboseResolutionMode.contains(VerboseResolutionMode.DEFERRED_INST)) { 5.135 + log.note(env.tree.pos, "deferred.method.inst", msym, mt, resultInfo.pt); 5.136 + } 5.137 } 5.138 - else { 5.139 + 5.140 + if (restvars.isEmpty() || resultInfo != null) { 5.141 // check that actuals conform to inferred formals 5.142 checkArgumentsAcceptable(env, capturedArgs, mt.getParameterTypes(), allowBoxing, useVarargs, warn); 5.143 - // return instantiated version of method type 5.144 - return mt; 5.145 } 5.146 + // return instantiated version of method type 5.147 + return mt; 5.148 } 5.149 //where 5.150 5.151 @@ -404,60 +397,6 @@ 5.152 } 5.153 } 5.154 5.155 - /** 5.156 - * A delegated type representing a partially uninferred method type. 5.157 - * The return type of a partially uninferred method type is a ForAll 5.158 - * type - when the return type is instantiated (see Infer.instantiateExpr) 5.159 - * the underlying method type is also updated. 5.160 - */ 5.161 - abstract class UninferredMethodType extends DelegatedType { 5.162 - 5.163 - final List<Type> tvars; 5.164 - final Symbol msym; 5.165 - final DiagnosticPosition pos; 5.166 - 5.167 - public UninferredMethodType(DiagnosticPosition pos, Symbol msym, MethodType mtype, List<Type> tvars) { 5.168 - super(METHOD, new MethodType(mtype.argtypes, null, mtype.thrown, mtype.tsym)); 5.169 - this.tvars = tvars; 5.170 - this.msym = msym; 5.171 - this.pos = pos; 5.172 - asMethodType().restype = new UninferredReturnType(tvars, mtype.restype); 5.173 - } 5.174 - 5.175 - @Override 5.176 - public MethodType asMethodType() { 5.177 - return qtype.asMethodType(); 5.178 - } 5.179 - 5.180 - @Override 5.181 - public Type map(Mapping f) { 5.182 - return qtype.map(f); 5.183 - } 5.184 - 5.185 - abstract void instantiateReturnType(Type restype, List<Type> inferred, Types types); 5.186 - 5.187 - abstract List<Type> undetvars(); 5.188 - 5.189 - class UninferredReturnType extends ForAll { 5.190 - public UninferredReturnType(List<Type> tvars, Type restype) { 5.191 - super(tvars, restype); 5.192 - } 5.193 - @Override 5.194 - public Type inst(List<Type> actuals, Types types) { 5.195 - Type newRestype = super.inst(actuals, types); 5.196 - instantiateReturnType(newRestype, actuals, types); 5.197 - if (rs.verboseResolutionMode.contains(VerboseResolutionMode.DEFERRED_INST)) { 5.198 - log.note(pos, "deferred.method.inst", msym, UninferredMethodType.this.qtype, newRestype); 5.199 - } 5.200 - return UninferredMethodType.this.qtype.getReturnType(); 5.201 - } 5.202 - @Override 5.203 - public List<Type> undetvars() { 5.204 - return UninferredMethodType.this.undetvars(); 5.205 - } 5.206 - } 5.207 - } 5.208 - 5.209 private void checkArgumentsAcceptable(Env<AttrContext> env, List<Type> actuals, List<Type> formals, 5.210 boolean allowBoxing, boolean useVarargs, Warner warn) { 5.211 try {
6.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Jun 07 12:10:41 2012 -0700 6.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Fri Jun 08 12:45:43 2012 -0700 6.3 @@ -248,7 +248,7 @@ 6.4 final Name name, 6.5 final Env<AttrContext> env) { 6.6 if (tsym.kind != TYP) { 6.7 - log.error(pos, "static.imp.only.classes.and.interfaces"); 6.8 + log.error(DiagnosticFlag.RECOVERABLE, pos, "static.imp.only.classes.and.interfaces"); 6.9 return; 6.10 } 6.11 6.12 @@ -620,7 +620,11 @@ 6.13 DeferredLintHandler prevLintHandler = 6.14 chk.setDeferredLintHandler(deferredLintHandler.setPos(tree.pos())); 6.15 try { 6.16 - attr.attribType(tree.vartype, localEnv); 6.17 + if (TreeInfo.isEnumInit(tree)) { 6.18 + attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype); 6.19 + } else { 6.20 + attr.attribType(tree.vartype, localEnv); 6.21 + } 6.22 } finally { 6.23 chk.setDeferredLintHandler(prevLintHandler); 6.24 }
7.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Jun 07 12:10:41 2012 -0700 7.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Jun 08 12:45:43 2012 -0700 7.3 @@ -224,12 +224,8 @@ 7.4 7.5 JCDiagnostic getVerboseApplicableCandidateDiag(int pos, Symbol sym, Type inst) { 7.6 JCDiagnostic subDiag = null; 7.7 - if (inst.getReturnType().tag == FORALL) { 7.8 - Type diagType = types.createMethodTypeWithReturn(inst.asMethodType(), 7.9 - ((ForAll)inst.getReturnType()).qtype); 7.10 - subDiag = diags.fragment("partial.inst.sig", diagType); 7.11 - } else if (sym.type.tag == FORALL) { 7.12 - subDiag = diags.fragment("full.inst.sig", inst.asMethodType()); 7.13 + if (sym.type.tag == FORALL) { 7.14 + subDiag = diags.fragment("partial.inst.sig", inst); 7.15 } 7.16 7.17 String key = subDiag == null ? 7.18 @@ -442,6 +438,7 @@ 7.19 Type rawInstantiate(Env<AttrContext> env, 7.20 Type site, 7.21 Symbol m, 7.22 + ResultInfo resultInfo, 7.23 List<Type> argtypes, 7.24 List<Type> typeargtypes, 7.25 boolean allowBoxing, 7.26 @@ -454,11 +451,7 @@ 7.27 7.28 // tvars is the list of formal type variables for which type arguments 7.29 // need to inferred. 7.30 - List<Type> tvars = null; 7.31 - if (env.info.tvars != null) { 7.32 - tvars = types.newInstances(env.info.tvars); 7.33 - mt = types.subst(mt, env.info.tvars, tvars); 7.34 - } 7.35 + List<Type> tvars = List.nil(); 7.36 if (typeargtypes == null) typeargtypes = List.nil(); 7.37 if (mt.tag != FORALL && typeargtypes.nonEmpty()) { 7.38 // This is not a polymorphic method, but typeargs are supplied 7.39 @@ -499,6 +492,7 @@ 7.40 return infer.instantiateMethod(env, 7.41 tvars, 7.42 (MethodType)mt, 7.43 + resultInfo, 7.44 m, 7.45 argtypes, 7.46 allowBoxing, 7.47 @@ -515,13 +509,14 @@ 7.48 Type instantiate(Env<AttrContext> env, 7.49 Type site, 7.50 Symbol m, 7.51 + ResultInfo resultInfo, 7.52 List<Type> argtypes, 7.53 List<Type> typeargtypes, 7.54 boolean allowBoxing, 7.55 boolean useVarargs, 7.56 Warner warn) { 7.57 try { 7.58 - return rawInstantiate(env, site, m, argtypes, typeargtypes, 7.59 + return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes, 7.60 allowBoxing, useVarargs, warn); 7.61 } catch (InapplicableMethodException ex) { 7.62 return null; 7.63 @@ -937,7 +932,7 @@ 7.64 if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar; 7.65 Assert.check(sym.kind < AMBIGUOUS); 7.66 try { 7.67 - Type mt = rawInstantiate(env, site, sym, argtypes, typeargtypes, 7.68 + Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes, 7.69 allowBoxing, useVarargs, Warner.noWarnings); 7.70 if (!operator) 7.71 currentResolutionContext.addApplicableCandidate(sym, mt); 7.72 @@ -1071,7 +1066,7 @@ 7.73 private boolean signatureMoreSpecific(Env<AttrContext> env, Type site, Symbol m1, Symbol m2, boolean allowBoxing, boolean useVarargs) { 7.74 noteWarner.clear(); 7.75 Type mtype1 = types.memberType(site, adjustVarargs(m1, m2, useVarargs)); 7.76 - Type mtype2 = instantiate(env, site, adjustVarargs(m2, m1, useVarargs), 7.77 + Type mtype2 = instantiate(env, site, adjustVarargs(m2, m1, useVarargs), null, 7.78 types.lowerBoundArgtypes(mtype1), null, 7.79 allowBoxing, false, noteWarner); 7.80 return mtype2 != null &&
8.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties Thu Jun 07 12:10:41 2012 -0700 8.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties Fri Jun 08 12:45:43 2012 -0700 8.3 @@ -419,9 +419,6 @@ 8.4 compiler.err.int.number.too.large=\ 8.5 integer number too large: {0} 8.6 8.7 -compiler.err.internal.error.cant.instantiate=\ 8.8 - internal error; cannot instantiate {0} at {1} to ({2}) 8.9 - 8.10 compiler.err.intf.annotation.members.cant.have.params=\ 8.11 @interface members may not have parameters 8.12 8.13 @@ -783,11 +780,6 @@ 8.14 compiler.err.undef.label=\ 8.15 undefined label: {0} 8.16 8.17 -# 0: list of type, 1: message segment 8.18 -compiler.misc.invalid.inferred.types=\ 8.19 - invalid inferred types for {0}\n\ 8.20 - reason: {1} 8.21 - 8.22 # 0: message segment, 1: unused 8.23 compiler.err.cant.apply.diamond=\ 8.24 cannot infer type arguments for {0} 8.25 @@ -1582,11 +1574,6 @@ 8.26 ## The following are all possible strings for the last argument of all those 8.27 ## diagnostics whose key ends in ".1" 8.28 8.29 -# 0: type, 1: message segment 8.30 -compiler.misc.undetermined.type=\ 8.31 - cannot infer type arguments for {0}\n\ 8.32 - reason: {1} 8.33 - 8.34 # 0: type, 1: list of type 8.35 compiler.misc.no.unique.maximal.instance.exists=\ 8.36 no unique maximal instance exists for type variable {0} with upper bounds {1} 8.37 @@ -1983,10 +1970,6 @@ 8.38 ({2}) 8.39 8.40 # 0: type 8.41 -compiler.misc.full.inst.sig=\ 8.42 - fully instantiated to: {0} 8.43 - 8.44 -# 0: type 8.45 compiler.misc.partial.inst.sig=\ 8.46 partially instantiated to: {0} 8.47
9.1 --- a/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu Jun 07 12:10:41 2012 -0700 9.2 +++ b/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri Jun 08 12:45:43 2012 -0700 9.3 @@ -237,6 +237,15 @@ 9.4 } 9.5 } 9.6 9.7 + public static boolean isEnumInit(JCTree tree) { 9.8 + switch (tree.getTag()) { 9.9 + case VARDEF: 9.10 + return (((JCVariableDecl)tree).mods.flags & ENUM) != 0; 9.11 + default: 9.12 + return false; 9.13 + } 9.14 + } 9.15 + 9.16 /** 9.17 * Return true if the AST corresponds to a static select of the kind A.B 9.18 */
10.1 --- a/test/tools/javac/6758789/T6758789b.out Thu Jun 07 12:10:41 2012 -0700 10.2 +++ b/test/tools/javac/6758789/T6758789b.out Fri Jun 08 12:45:43 2012 -0700 10.3 @@ -1,4 +1,4 @@ 10.4 -T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<X> 10.5 +T6758789b.java:16:11: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T6758789a.Foo, T6758789a.Foo<java.lang.Object> 10.6 T6758789b.java:16:10: compiler.warn.unchecked.meth.invocation.applied: kindname.method, m, T6758789a.Foo<X>, T6758789a.Foo, kindname.class, T6758789a 10.7 - compiler.err.warnings.and.werror 10.8 1 error
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/tools/javac/T7159016.java Fri Jun 08 12:45:43 2012 -0700 11.3 @@ -0,0 +1,89 @@ 11.4 +/* 11.5 + * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 11.7 + * 11.8 + * This code is free software; you can redistribute it and/or modify it 11.9 + * under the terms of the GNU General Public License version 2 only, as 11.10 + * published by the Free Software Foundation. 11.11 + * 11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.15 + * version 2 for more details (a copy is included in the LICENSE file that 11.16 + * accompanied this code). 11.17 + * 11.18 + * You should have received a copy of the GNU General Public License version 11.19 + * 2 along with this work; if not, write to the Free Software Foundation, 11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.21 + * 11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.23 + * or visit www.oracle.com if you need additional information or have any 11.24 + * questions. 11.25 + */ 11.26 + 11.27 +/* 11.28 + * @test 11.29 + * @bug 7159016 11.30 + * @summary Static import of member in processor-generated class fails in JDK 7 11.31 + * @library lib 11.32 + * @build JavacTestingAbstractProcessor 11.33 + * @run main T7159016 11.34 + * @author Jessie Glick 11.35 + */ 11.36 + 11.37 +import java.io.File; 11.38 +import java.io.FileWriter; 11.39 +import java.io.IOException; 11.40 +import java.io.Writer; 11.41 +import java.util.Collections; 11.42 +import java.util.Set; 11.43 +import javax.annotation.processing.AbstractProcessor; 11.44 +import javax.annotation.processing.RoundEnvironment; 11.45 +import javax.annotation.processing.SupportedAnnotationTypes; 11.46 +import javax.annotation.processing.SupportedSourceVersion; 11.47 +import javax.lang.model.SourceVersion; 11.48 +import javax.lang.model.element.TypeElement; 11.49 +import javax.tools.Diagnostic; 11.50 +import javax.tools.JavaCompiler; 11.51 +import javax.tools.ToolProvider; 11.52 + 11.53 +public class T7159016 { 11.54 + public static void main(String[] args) throws Exception { 11.55 + File src = new File("C.java"); 11.56 + Writer w = new FileWriter(src); 11.57 + try { 11.58 + w.write("import static p.Generated.m;\nclass C { {m(); } }\n"); 11.59 + w.flush(); 11.60 + } finally { 11.61 + w.close(); 11.62 + } 11.63 + JavaCompiler jc = ToolProvider.getSystemJavaCompiler(); 11.64 + JavaCompiler.CompilationTask task = jc.getTask(null, null, null, null, null, 11.65 + jc.getStandardFileManager(null, null, null).getJavaFileObjects(src)); 11.66 + task.setProcessors(Collections.singleton(new Proc())); 11.67 + if (!task.call()) { 11.68 + throw new Error("Test failed"); 11.69 + } 11.70 + } 11.71 + 11.72 + private static class Proc extends JavacTestingAbstractProcessor { 11.73 + int written; 11.74 + @Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 11.75 + if (roundEnv.processingOver() || written++ > 0) { 11.76 + return false; 11.77 + } 11.78 + messager.printMessage(Diagnostic.Kind.NOTE, "writing Generated.java"); 11.79 + try { 11.80 + Writer w = processingEnv.getFiler().createSourceFile("p.Generated").openWriter(); 11.81 + try { 11.82 + w.write("package p; public class Generated { public static void m() { } }"); 11.83 + } finally { 11.84 + w.close(); 11.85 + } 11.86 + } catch (IOException x) { 11.87 + messager.printMessage(Diagnostic.Kind.ERROR, x.toString()); 11.88 + } 11.89 + return true; 11.90 + } 11.91 + } 11.92 +}
12.1 --- a/test/tools/javac/diags/examples.not-yet.txt Thu Jun 07 12:10:41 2012 -0700 12.2 +++ b/test/tools/javac/diags/examples.not-yet.txt Fri Jun 08 12:45:43 2012 -0700 12.3 @@ -5,7 +5,6 @@ 12.4 compiler.err.cant.read.file # (apt.JavaCompiler?) 12.5 compiler.err.cant.select.static.class.from.param.type 12.6 compiler.err.illegal.char.for.encoding 12.7 -compiler.err.internal.error.cant.instantiate # Attr: should not happen 12.8 compiler.err.io.exception # (javah.JavahTask?) 12.9 compiler.err.limit.code # Code 12.10 compiler.err.limit.code.too.large.for.try.stmt # Gen
13.1 --- a/test/tools/javac/diags/examples/ApplicableMethodFound1.java Thu Jun 07 12:10:41 2012 -0700 13.2 +++ b/test/tools/javac/diags/examples/ApplicableMethodFound1.java Fri Jun 08 12:45:43 2012 -0700 13.3 @@ -23,7 +23,7 @@ 13.4 13.5 // key: compiler.misc.applicable.method.found.1 13.6 // key: compiler.note.verbose.resolve.multi 13.7 -// key: compiler.misc.full.inst.sig 13.8 +// key: compiler.misc.partial.inst.sig 13.9 // options: -XDverboseResolution=applicable,success 13.10 13.11 class ApplicableMethodFound1 {
14.1 --- a/test/tools/javac/diags/examples/CantApplyDiamond1.java Thu Jun 07 12:10:41 2012 -0700 14.2 +++ b/test/tools/javac/diags/examples/CantApplyDiamond1.java Fri Jun 08 12:45:43 2012 -0700 14.3 @@ -23,7 +23,7 @@ 14.4 14.5 // key: compiler.err.prob.found.req.1 14.6 // key: compiler.misc.cant.apply.diamond.1 14.7 -// key: compiler.misc.no.conforming.assignment.exists 14.8 +// key: compiler.misc.inferred.do.not.conform.to.upper.bounds 14.9 // key: compiler.misc.diamond 14.10 14.11 class CantApplyDiamond1<X> {
15.1 --- a/test/tools/javac/diags/examples/FullInstSig.java Thu Jun 07 12:10:41 2012 -0700 15.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 15.3 @@ -1,34 +0,0 @@ 15.4 -/* 15.5 - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. 15.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.7 - * 15.8 - * This code is free software; you can redistribute it and/or modify it 15.9 - * under the terms of the GNU General Public License version 2 only, as 15.10 - * published by the Free Software Foundation. 15.11 - * 15.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 15.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.15 - * version 2 for more details (a copy is included in the LICENSE file that 15.16 - * accompanied this code). 15.17 - * 15.18 - * You should have received a copy of the GNU General Public License version 15.19 - * 2 along with this work; if not, write to the Free Software Foundation, 15.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.21 - * 15.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 15.23 - * or visit www.oracle.com if you need additional information or have any 15.24 - * questions. 15.25 - */ 15.26 - 15.27 -// key: compiler.misc.applicable.method.found.1 15.28 -// key: compiler.note.verbose.resolve.multi 15.29 -// key: compiler.misc.full.inst.sig 15.30 -// options: -XDverboseResolution=applicable,success 15.31 - 15.32 -class FullInstSig { 15.33 - 15.34 - <X> void m(X x) {} 15.35 - 15.36 - { m(1); } 15.37 -}
16.1 --- a/test/tools/javac/diags/examples/IncompatibleTypes1.java Thu Jun 07 12:10:41 2012 -0700 16.2 +++ b/test/tools/javac/diags/examples/IncompatibleTypes1.java Fri Jun 08 12:45:43 2012 -0700 16.3 @@ -22,7 +22,7 @@ 16.4 */ 16.5 16.6 // key: compiler.misc.infer.no.conforming.instance.exists 16.7 -// key: compiler.err.prob.found.req.1 16.8 +// key: compiler.err.cant.apply.symbol.1 16.9 16.10 class IncompatibleTypes1<V> { 16.11 <T> IncompatibleTypes1<Integer> m() {
17.1 --- a/test/tools/javac/diags/examples/InferredDoNotConformToLower.java Thu Jun 07 12:10:41 2012 -0700 17.2 +++ b/test/tools/javac/diags/examples/InferredDoNotConformToLower.java Fri Jun 08 12:45:43 2012 -0700 17.3 @@ -21,8 +21,7 @@ 17.4 * questions. 17.5 */ 17.6 17.7 -// key: compiler.misc.invalid.inferred.types 17.8 -// key: compiler.err.prob.found.req.1 17.9 +// key: compiler.err.cant.apply.symbol.1 17.10 // key: compiler.misc.inferred.do.not.conform.to.lower.bounds 17.11 17.12 import java.util.*;
18.1 --- a/test/tools/javac/diags/examples/InvalidInferredTypes.java Thu Jun 07 12:10:41 2012 -0700 18.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 18.3 @@ -1,37 +0,0 @@ 18.4 -/* 18.5 - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. 18.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 18.7 - * 18.8 - * This code is free software; you can redistribute it and/or modify it 18.9 - * under the terms of the GNU General Public License version 2 only, as 18.10 - * published by the Free Software Foundation. 18.11 - * 18.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 18.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 18.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 18.15 - * version 2 for more details (a copy is included in the LICENSE file that 18.16 - * accompanied this code). 18.17 - * 18.18 - * You should have received a copy of the GNU General Public License version 18.19 - * 2 along with this work; if not, write to the Free Software Foundation, 18.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18.21 - * 18.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 18.23 - * or visit www.oracle.com if you need additional information or have any 18.24 - * questions. 18.25 - */ 18.26 - 18.27 -// key: compiler.err.prob.found.req.1 18.28 -// key: compiler.misc.invalid.inferred.types 18.29 -// key: compiler.misc.inferred.do.not.conform.to.upper.bounds 18.30 - 18.31 -import java.util.*; 18.32 - 18.33 -class InvalidInferredTypes { 18.34 - 18.35 - <S extends String> List<S> m() { return null; } 18.36 - 18.37 - void test() { 18.38 - List<Integer> li = m(); 18.39 - } 18.40 -}
19.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 19.2 +++ b/test/tools/javac/diags/examples/NoUniqueMaximalInstance.java Fri Jun 08 12:45:43 2012 -0700 19.3 @@ -0,0 +1,31 @@ 19.4 +/* 19.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 19.7 + * 19.8 + * This code is free software; you can redistribute it and/or modify it 19.9 + * under the terms of the GNU General Public License version 2 only, as 19.10 + * published by the Free Software Foundation. 19.11 + * 19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 19.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 19.15 + * version 2 for more details (a copy is included in the LICENSE file that 19.16 + * accompanied this code). 19.17 + * 19.18 + * You should have received a copy of the GNU General Public License version 19.19 + * 2 along with this work; if not, write to the Free Software Foundation, 19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19.21 + * 19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 19.23 + * or visit www.oracle.com if you need additional information or have any 19.24 + * questions. 19.25 + */ 19.26 + 19.27 +// key: compiler.err.cant.apply.symbol.1 19.28 +// key: compiler.misc.no.unique.maximal.instance.exists 19.29 + 19.30 +class NoUniqueMaximalInstance { 19.31 + <Z extends Integer> Z m() { return null; } 19.32 + 19.33 + { String s = m(); } 19.34 +}
20.1 --- a/test/tools/javac/diags/examples/UndeterminedType1.java Thu Jun 07 12:10:41 2012 -0700 20.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 20.3 @@ -1,35 +0,0 @@ 20.4 -/* 20.5 - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. 20.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 20.7 - * 20.8 - * This code is free software; you can redistribute it and/or modify it 20.9 - * under the terms of the GNU General Public License version 2 only, as 20.10 - * published by the Free Software Foundation. 20.11 - * 20.12 - * This code is distributed in the hope that it will be useful, but WITHOUT 20.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 20.14 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 20.15 - * version 2 for more details (a copy is included in the LICENSE file that 20.16 - * accompanied this code). 20.17 - * 20.18 - * You should have received a copy of the GNU General Public License version 20.19 - * 2 along with this work; if not, write to the Free Software Foundation, 20.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20.21 - * 20.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20.23 - * or visit www.oracle.com if you need additional information or have any 20.24 - * questions. 20.25 - */ 20.26 - 20.27 -// key: compiler.err.prob.found.req.1 20.28 -// key: compiler.misc.undetermined.type 20.29 -// key: compiler.misc.no.unique.maximal.instance.exists 20.30 - 20.31 -class UndeterminedType1<V> { 20.32 - <T extends Integer & Runnable> UndeterminedType1<T> m() { 20.33 - return null; 20.34 - } 20.35 - 20.36 - 20.37 - UndeterminedType1<? extends String> c2 = m(); 20.38 -}
21.1 --- a/test/tools/javac/diags/examples/WhereFreshTvar.java Thu Jun 07 12:10:41 2012 -0700 21.2 +++ b/test/tools/javac/diags/examples/WhereFreshTvar.java Fri Jun 08 12:45:43 2012 -0700 21.3 @@ -22,10 +22,9 @@ 21.4 */ 21.5 21.6 // key: compiler.misc.where.fresh.typevar 21.7 -// key: compiler.misc.where.description.typevar.1 21.8 -// key: compiler.misc.where.typevar 21.9 -// key: compiler.misc.invalid.inferred.types 21.10 -// key: compiler.err.prob.found.req.1 21.11 +// key: compiler.misc.where.description.typevar 21.12 +// key: compiler.err.cant.apply.symbol.1 21.13 +// key: compiler.misc.no.args 21.14 // key: compiler.misc.inferred.do.not.conform.to.upper.bounds 21.15 // options: -XDdiags=where,simpleNames 21.16 // run: simple
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/test/tools/javac/enum/7160084/T7160084a.java Fri Jun 08 12:45:43 2012 -0700 22.3 @@ -0,0 +1,60 @@ 22.4 +/* 22.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.7 + * 22.8 + * This code is free software; you can redistribute it and/or modify it 22.9 + * under the terms of the GNU General Public License version 2 only, as 22.10 + * published by the Free Software Foundation. 22.11 + * 22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 22.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22.15 + * version 2 for more details (a copy is included in the LICENSE file that 22.16 + * accompanied this code). 22.17 + * 22.18 + * You should have received a copy of the GNU General Public License version 22.19 + * 2 along with this work; if not, write to the Free Software Foundation, 22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22.21 + * 22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22.23 + * or visit www.oracle.com if you need additional information or have any 22.24 + * questions. 22.25 + */ 22.26 + 22.27 +/* 22.28 + * @test 22.29 + * @bug 7160084 22.30 + * @summary javac fails to compile an apparently valid class/interface combination 22.31 + */ 22.32 +public class T7160084a { 22.33 + 22.34 + static int assertionCount = 0; 22.35 + 22.36 + static void assertTrue(boolean cond) { 22.37 + assertionCount++; 22.38 + if (!cond) { 22.39 + throw new AssertionError(); 22.40 + } 22.41 + } 22.42 + 22.43 + interface Intf { 22.44 + enum MyEnumA { 22.45 + AA(""), 22.46 + UNUSED(""); 22.47 + 22.48 + private MyEnumA(String s) { } 22.49 + } 22.50 + } 22.51 + 22.52 + enum MyEnumA implements Intf { 22.53 + AA(""); 22.54 + 22.55 + private MyEnumA(String s) { } 22.56 + } 22.57 + 22.58 + public static void main(String... args) { 22.59 + assertTrue(MyEnumA.values().length == 1); 22.60 + assertTrue(Intf.MyEnumA.values().length == 2); 22.61 + assertTrue(assertionCount == 2); 22.62 + } 22.63 +}
23.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 23.2 +++ b/test/tools/javac/enum/7160084/T7160084b.java Fri Jun 08 12:45:43 2012 -0700 23.3 @@ -0,0 +1,68 @@ 23.4 +/* 23.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 23.7 + * 23.8 + * This code is free software; you can redistribute it and/or modify it 23.9 + * under the terms of the GNU General Public License version 2 only, as 23.10 + * published by the Free Software Foundation. 23.11 + * 23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 23.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 23.15 + * version 2 for more details (a copy is included in the LICENSE file that 23.16 + * accompanied this code). 23.17 + * 23.18 + * You should have received a copy of the GNU General Public License version 23.19 + * 2 along with this work; if not, write to the Free Software Foundation, 23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 23.21 + * 23.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23.23 + * or visit www.oracle.com if you need additional information or have any 23.24 + * questions. 23.25 + */ 23.26 + 23.27 +/* 23.28 + * @test 23.29 + * @bug 7160084 23.30 + * @summary javac fails to compile an apparently valid class/interface combination 23.31 + */ 23.32 +public class T7160084b { 23.33 + 23.34 + static int assertionCount = 0; 23.35 + 23.36 + static void assertTrue(boolean cond) { 23.37 + assertionCount++; 23.38 + if (!cond) { 23.39 + throw new AssertionError(); 23.40 + } 23.41 + } 23.42 + 23.43 + interface Extras { 23.44 + static class Enums { 23.45 + static class Component { 23.46 + Component() { throw new RuntimeException("oops!"); } 23.47 + } 23.48 + } 23.49 + } 23.50 + 23.51 + interface Test { 23.52 + public class Enums { 23.53 + interface Widget { 23.54 + enum Component { X, Y }; 23.55 + } 23.56 + 23.57 + enum Component implements Widget, Extras { 23.58 + Z; 23.59 + }; 23.60 + 23.61 + public static void test() { 23.62 + assertTrue(Component.values().length == 1); 23.63 + } 23.64 + } 23.65 + } 23.66 + 23.67 + public static void main(String[] args) { 23.68 + Test.Enums.test(); 23.69 + assertTrue(assertionCount == 1); 23.70 + } 23.71 +}
24.1 --- a/test/tools/javac/generics/7015430/T7015430.out Thu Jun 07 12:10:41 2012 -0700 24.2 +++ b/test/tools/javac/generics/7015430/T7015430.out Fri Jun 08 12:45:43 2012 -0700 24.3 @@ -1,14 +1,14 @@ 24.4 -T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E> 24.5 +T7015430.java:41:15: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception> 24.6 T7015430.java:41:14: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430 24.7 T7015430.java:50:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException> 24.8 T7015430.java:50:41: compiler.warn.unchecked.meth.invocation.applied: kindname.method, empty, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430 24.9 -T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E> 24.10 +T7015430.java:68:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception> 24.11 T7015430.java:68:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430 24.12 T7015430.java:77:40: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException> 24.13 T7015430.java:77:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430 24.14 T7015430.java:104:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.RuntimeException> 24.15 T7015430.java:104:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430 24.16 -T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<E> 24.17 +T7015430.java:113:22: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), java.lang.Iterable, java.lang.Iterable<java.lang.Exception> 24.18 T7015430.java:113:9: compiler.warn.unchecked.meth.invocation.applied: kindname.constructor, <init>, java.lang.Iterable<E>, java.lang.Iterable, kindname.class, T7015430 24.19 T7015430.java:41:14: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception 24.20 T7015430.java:68:9: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
25.1 --- a/test/tools/javac/generics/7151802/T7151802.out Thu Jun 07 12:10:41 2012 -0700 25.2 +++ b/test/tools/javac/generics/7151802/T7151802.out Fri Jun 08 12:45:43 2012 -0700 25.3 @@ -1,5 +1,5 @@ 25.4 T7151802.java:14:31: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get1, Z, T7151802.Foo, kindname.class, T7151802 25.5 -T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<Z> 25.6 +T7151802.java:22:31: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.Object> 25.7 T7151802.java:22:30: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get3, T7151802.Foo<Z>, T7151802.Foo, kindname.class, T7151802 25.8 T7151802.java:30:36: compiler.warn.unchecked.meth.invocation.applied: kindname.method, get5, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7151802 25.9 T7151802.java:38:32: compiler.warn.prob.found.req: (compiler.misc.unchecked.assign), T7151802.Foo, T7151802.Foo<java.lang.String>
26.1 --- a/test/tools/javac/generics/inference/6315770/T6315770.out Thu Jun 07 12:10:41 2012 -0700 26.2 +++ b/test/tools/javac/generics/inference/6315770/T6315770.out Fri Jun 08 12:45:43 2012 -0700 26.3 @@ -1,3 +1,3 @@ 26.4 -T6315770.java:16:42: compiler.err.prob.found.req.1: (compiler.misc.undetermined.type: <T>T6315770<T>, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable)) 26.5 -T6315770.java:17:40: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer&java.lang.Runnable, java.lang.String)) 26.6 +T6315770.java:16:42: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T6315770<V>, (compiler.misc.no.unique.maximal.instance.exists: T, java.lang.String,java.lang.Integer,java.lang.Runnable) 26.7 +T6315770.java:17:40: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T6315770<V>, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer&java.lang.Runnable, java.lang.String) 26.8 2 errors
27.1 --- a/test/tools/javac/generics/inference/6638712/T6638712b.out Thu Jun 07 12:10:41 2012 -0700 27.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712b.out Fri Jun 08 12:45:43 2012 -0700 27.3 @@ -1,2 +1,2 @@ 27.4 -T6638712b.java:14:21: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String,java.lang.Object)) 27.5 +T6638712b.java:14:21: compiler.err.cant.apply.symbol.1: kindname.method, m, I, T6638712b<java.lang.Integer>, kindname.class, T6638712b<X>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, java.lang.String,java.lang.Object) 27.6 1 error
28.1 --- a/test/tools/javac/generics/inference/6638712/T6638712e.out Thu Jun 07 12:10:41 2012 -0700 28.2 +++ b/test/tools/javac/generics/inference/6638712/T6638712e.out Fri Jun 08 12:45:43 2012 -0700 28.3 @@ -1,2 +1,2 @@ 28.4 -T6638712e.java:17:27: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.no.conforming.assignment.exists: T6638712e.Foo<java.lang.Boolean,java.lang.Boolean>, T6638712e.Foo<? super java.lang.Object,? extends java.lang.Boolean>)) 28.5 +T6638712e.java:17:27: compiler.err.cant.apply.symbol.1: kindname.method, m, T6638712e.Foo<? super X,? extends A>, T6638712e.Foo<java.lang.Boolean,java.lang.Boolean>, kindname.class, T6638712e.Foo<A,B>, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Object, java.lang.Boolean,java.lang.Object) 28.6 1 error
29.1 --- a/test/tools/javac/generics/inference/6650759/T6650759m.out Thu Jun 07 12:10:41 2012 -0700 29.2 +++ b/test/tools/javac/generics/inference/6650759/T6650759m.out Fri Jun 08 12:45:43 2012 -0700 29.3 @@ -1,2 +1,2 @@ 29.4 -T6650759m.java:43:36: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: Z, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer, java.lang.String)) 29.5 +T6650759m.java:43:36: compiler.err.cant.apply.symbol.1: kindname.method, m, java.util.List<? extends java.util.List<? super Z>>, java.util.ArrayList<java.util.ArrayList<java.lang.Integer>>, kindname.class, T6650759m, (compiler.misc.inferred.do.not.conform.to.lower.bounds: java.lang.Integer, java.lang.String) 29.6 1 error
30.1 --- a/test/tools/javac/generics/inference/7154127/T7154127.out Thu Jun 07 12:10:41 2012 -0700 30.2 +++ b/test/tools/javac/generics/inference/7154127/T7154127.out Fri Jun 08 12:45:43 2012 -0700 30.3 @@ -1,2 +1,2 @@ 30.4 -T7154127.java:19:49: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: T,Y,U, (compiler.misc.inferred.do.not.conform.to.upper.bounds: Y, T7154127.D,T7154127.B<U>)) 30.5 +T7154127.java:19:49: compiler.err.cant.apply.symbol.1: kindname.method, m, compiler.misc.no.args, compiler.misc.no.args, kindname.class, T7154127, (compiler.misc.inferred.do.not.conform.to.upper.bounds: Y, T7154127.D,T7154127.B<U>) 30.6 1 error
31.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 31.2 +++ b/test/tools/javac/generics/rawOverride/7157798/Test1.java Fri Jun 08 12:45:43 2012 -0700 31.3 @@ -0,0 +1,116 @@ 31.4 +/* 31.5 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 31.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 31.7 + * 31.8 + * This code is free software; you can redistribute it and/or modify it 31.9 + * under the terms of the GNU General Public License version 2 only, as 31.10 + * published by the Free Software Foundation. 31.11 + * 31.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 31.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 31.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 31.15 + * version 2 for more details (a copy is included in the LICENSE file that 31.16 + * accompanied this code). 31.17 + * 31.18 + * You should have received a copy of the GNU General Public License version 31.19 + * 2 along with this work; if not, write to the Free Software Foundation, 31.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 31.21 + * 31.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 31.23 + * or visit www.oracle.com if you need additional information or have any 31.24 + * questions. 31.25 + */ 31.26 + 31.27 +/** 31.28 + * @test 31.29 + * @bug 7062745 7157798 31.30 + * @summary Test inheritance of same-name methods from mulitple interfaces 31.31 + when the methods have compatible return types 31.32 + * @compile Test1.java 31.33 + */ 31.34 + 31.35 +import java.util.*; 31.36 + 31.37 +interface A { List<Number> getList(); } 31.38 +interface B { List getList(); } 31.39 + 31.40 +interface AB extends A, B {} //return type: List<Number> 31.41 + 31.42 +interface C<T> { List<T> getList(); } 31.43 + 31.44 +interface BC<T> extends B, C<T> {} //return type: List<T> 31.45 + 31.46 +interface D { Number m(); } 31.47 +interface E { Double m(); } 31.48 + 31.49 +interface DE extends D, E {} //return type: Double 31.50 + 31.51 +interface F { ArrayList getList(); } 31.52 +interface G { Collection getList(); } 31.53 + 31.54 +interface AG extends A, G{}; //return type: List<Number> 31.55 + 31.56 +interface CF<T> extends C<T>, F {} //return type: ArrayList 31.57 + 31.58 +interface CG<T> extends C<T>, G {} //return type: List<T> 31.59 + 31.60 +interface H<T> { Iterable<T> getList(); } 31.61 + 31.62 +interface CH<T> extends C<T>, H<T> {} //return type: List<T> 31.63 + 31.64 +interface CFGH<T> extends C<T>, F, G, H<T> {} //return type: ArrayList 31.65 + 31.66 + 31.67 +class Test1 { 31.68 + 31.69 + //raw and typed return types: 31.70 + void test(AB ab) { 31.71 + Number n = ab.getList().get(1); 31.72 + } 31.73 + 31.74 + void test(BC<String> bc) { 31.75 + String s = bc.getList().get(1); 31.76 + } 31.77 + 31.78 + void testRaw(BC bc) { 31.79 + List list = bc.getList(); 31.80 + } 31.81 + 31.82 + void testWildCard(BC<?> bc) { 31.83 + List<?> list = bc.getList(); 31.84 + } 31.85 + 31.86 + <T> void testGeneric(BC<T> bc) { 31.87 + T t = bc.getList().get(1); 31.88 + } 31.89 + 31.90 + //covariant return: 31.91 + void test(DE de) { 31.92 + Double d = de.m(); 31.93 + } 31.94 + 31.95 + //mixed: 31.96 + void test(AG ag) { 31.97 + Number n = ag.getList().get(0); 31.98 + } 31.99 + 31.100 + void test(CF<Integer> cf) { 31.101 + ArrayList list = cf.getList(); 31.102 + } 31.103 + 31.104 + void test(CG<String> cg) { 31.105 + String s = cg.getList().get(0); 31.106 + } 31.107 + 31.108 + void test(CH<String> ch) { 31.109 + String s = ch.getList().get(0); 31.110 + } 31.111 + 31.112 + void test(CFGH<Double> cfgh) { 31.113 + ArrayList list = cfgh.getList(); 31.114 + } 31.115 + 31.116 + void testWildCard(CFGH<?> cfgh) { 31.117 + ArrayList list = cfgh.getList(); 31.118 + } 31.119 +}
32.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 32.2 +++ b/test/tools/javac/generics/rawOverride/7157798/Test2.java Fri Jun 08 12:45:43 2012 -0700 32.3 @@ -0,0 +1,76 @@ 32.4 +/* 32.5 + * Copyright (c) 2012, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 32.23 + * or visit www.oracle.com if you need additional information or have any 32.24 + * questions. 32.25 + */ 32.26 + 32.27 +/** 32.28 + * @test 32.29 + * @bug 7062745 7157798 32.30 + * @summary Test inheritance of same-name methods from multiple interfaces 32.31 + when the methods have compatible parameter types and return types 32.32 + * @compile Test2.java 32.33 + */ 32.34 + 32.35 +import java.util.*; 32.36 + 32.37 +interface A { void m(Map map); } 32.38 +interface B { void m(Map<Number, String> map); } 32.39 + 32.40 +interface AB extends A, B {} //paramter type: Map<Number, String> 32.41 + 32.42 +interface C<K, V> { List<V> getList(Map<K, V> map); } 32.43 +interface D { ArrayList getList(Map map); } 32.44 + 32.45 +interface CD<K, V> extends C<K, V>, D {} //paramter type: Map<K, V> 32.46 + 32.47 +interface E<T> { T get(List<?> list); } 32.48 +interface F<T> { T get(List list); } 32.49 + 32.50 +interface EF<T1, T2 extends T1> extends E<T1>, F<T2> {} //parameter type: List<?> 32.51 + 32.52 +class Test2 { 32.53 + 32.54 + //compatible parameter types: 32.55 + void test(AB ab) { 32.56 + ab.m(new HashMap<Number, String>()); 32.57 + } 32.58 + 32.59 + //compatible parameter types and return types: 32.60 + void testRaw(CD cd) { //return type: ArrayList 32.61 + ArrayList al = cd.getList(new HashMap()); 32.62 + } 32.63 + 32.64 + <K, V> void testGeneric(CD<K, V> cd) { //return type: List<V> 32.65 + V v = cd.getList(new HashMap<K, V>()).get(0); 32.66 + } 32.67 + 32.68 + void test(CD<Number, String> cd) { //return type: List<String> 32.69 + String s = cd.getList(new HashMap<Number, String>()).get(0); 32.70 + } 32.71 + 32.72 + void test(EF<Number, Integer> ef) { //return type: Number 32.73 + Number n = ef.get(new ArrayList<Integer>()); 32.74 + } 32.75 + 32.76 + <T, U extends T> void testGeneric(EF<T, U> ef) { //return type: T 32.77 + T t = ef.get(new ArrayList<U>()); 32.78 + } 32.79 +}
33.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 33.2 +++ b/test/tools/javac/generics/rawOverride/7157798/Test3.java Fri Jun 08 12:45:43 2012 -0700 33.3 @@ -0,0 +1,37 @@ 33.4 +/** 33.5 + * @test /nodynamiccopyright/ 33.6 + * @bug 7062745 7157798 33.7 + * @summary Negative test of conflicting same-name methods inherited from multiple interfaces when return type not compatible 33.8 + * @compile/fail/ref=Test3.out -Werror -Xlint:unchecked -XDrawDiagnostics Test3.java 33.9 + */ 33.10 + 33.11 +import java.util.List; 33.12 +import java.io.Serializable; 33.13 + 33.14 +interface A { int m(); } 33.15 +interface B { Integer m(); } 33.16 + 33.17 +interface AB extends A, B {} //error 33.18 + 33.19 +interface C { List<Integer> m(); } 33.20 +interface D { List<Number> m(); } 33.21 + 33.22 +interface CD extends C, D {} //error 33.23 + 33.24 +interface E<T> { T m(); } 33.25 +interface F<T> { T m(); } 33.26 +interface G { Serializable m(); } 33.27 + 33.28 +interface BE extends B, E<Number> {} //ok, covariant return 33.29 + 33.30 +interface BE2<T> extends B, E<T> {} //error 33.31 + 33.32 +interface EF<T> extends E<T>, F<T> {} //ok 33.33 + 33.34 +interface EF2<U, V extends U> extends E<U>, F<V> {} //ok, covariant return 33.35 + 33.36 +interface EF3<U, V> extends E<U>, F<V> {} //error 33.37 + 33.38 +interface EG<T extends Number> extends E<T>, G {} //ok 33.39 + 33.40 +interface EFG<U extends Serializable, V extends Serializable> extends E<U>, F<V>, G {} //error
34.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 34.2 +++ b/test/tools/javac/generics/rawOverride/7157798/Test3.out Fri Jun 08 12:45:43 2012 -0700 34.3 @@ -0,0 +1,6 @@ 34.4 +Test3.java:14:1: compiler.err.types.incompatible.diff.ret: B, A, m() 34.5 +Test3.java:19:1: compiler.err.types.incompatible.diff.ret: D, C, m() 34.6 +Test3.java:27:1: compiler.err.types.incompatible.diff.ret: E<T>, B, m() 34.7 +Test3.java:33:1: compiler.err.types.incompatible.diff.ret: F<V>, E<U>, m() 34.8 +Test3.java:37:1: compiler.err.types.incompatible.diff.ret: F<V>, E<U>, m() 34.9 +5 errors
35.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 35.2 +++ b/test/tools/javac/generics/rawOverride/7157798/Test4.java Fri Jun 08 12:45:43 2012 -0700 35.3 @@ -0,0 +1,29 @@ 35.4 +/** 35.5 + * @test /nodynamiccopyright/ 35.6 + * @bug 7062745 7157798 35.7 + * @summary Negative test of conflicting same-name methods inherited from multiple interfaces when parameter types not compatible 35.8 + * @compile/fail/ref=Test4.out -Werror -Xlint:unchecked -XDrawDiagnostics Test4.java 35.9 + */ 35.10 + 35.11 +import java.util.Set; 35.12 +import java.util.HashSet; 35.13 + 35.14 +interface A { void m(Set<Integer> s); } 35.15 +interface B { void m(Set<String> s); } 35.16 +interface C { void m(Set<?> s); } 35.17 + 35.18 +interface AB extends A, B {} //error 35.19 + 35.20 +interface AC extends A, C {} //error 35.21 + 35.22 +interface D<T> { void m(Set<T> s); } 35.23 + 35.24 +interface AD extends A, D<Integer> {} //OK 35.25 + 35.26 +interface AD2 extends A, D<Number> {} //error 35.27 + 35.28 +interface CD<T> extends C, D<T> {} //error 35.29 + 35.30 +interface E { <T> void m(Set<T> s); } 35.31 + 35.32 +interface DE<T> extends D<T>, E {} //error
36.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 36.2 +++ b/test/tools/javac/generics/rawOverride/7157798/Test4.out Fri Jun 08 12:45:43 2012 -0700 36.3 @@ -0,0 +1,6 @@ 36.4 +Test4.java:15:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<java.lang.String>), B, m(java.util.Set<java.lang.Integer>), A 36.5 +Test4.java:17:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<?>), C, m(java.util.Set<java.lang.Integer>), A 36.6 +Test4.java:23:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<T>), D, m(java.util.Set<java.lang.Integer>), A 36.7 +Test4.java:25:1: compiler.err.name.clash.same.erasure.no.override: m(java.util.Set<T>), D, m(java.util.Set<?>), C 36.8 +Test4.java:29:1: compiler.err.name.clash.same.erasure.no.override: <T>m(java.util.Set<T>), E, m(java.util.Set<T>), D 36.9 +5 errors
37.1 --- a/test/tools/javac/varargs/6313164/T6313164.out Thu Jun 07 12:10:41 2012 -0700 37.2 +++ b/test/tools/javac/varargs/6313164/T6313164.out Fri Jun 08 12:45:43 2012 -0700 37.3 @@ -1,6 +1,6 @@ 37.4 T6313164.java:12:8: compiler.err.cant.apply.symbol.1: kindname.method, foo1, p1.A[], p1.B,p1.B, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) 37.5 -T6313164.java:14:13: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)) 37.6 -T6313164.java:15:13: compiler.err.prob.found.req.1: (compiler.misc.invalid.inferred.types: X, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164)) 37.7 +T6313164.java:14:13: compiler.err.cant.apply.symbol.1: kindname.method, foo3, X[], compiler.misc.type.null,compiler.misc.type.null, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) 37.8 +T6313164.java:15:13: compiler.err.cant.apply.symbol.1: kindname.method, foo4, X[], compiler.misc.type.null,compiler.misc.type.null, kindname.class, p1.B, (compiler.misc.inaccessible.varargs.type: p1.A, kindname.class, T6313164) 37.9 - compiler.note.unchecked.filename: B.java 37.10 - compiler.note.unchecked.recompile 37.11 3 errors