Fri, 15 Nov 2013 11:08:12 +0000
8026231: Look at 'static' flag when checking method references
Reviewed-by: jjg, dlsmith
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Kinds.java Thu Nov 14 13:47:38 2013 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Kinds.java Fri Nov 15 11:08:12 2013 +0000 1.3 @@ -87,16 +87,17 @@ 1.4 1.5 /** Kinds for erroneous symbols that complement the above 1.6 */ 1.7 - public static final int ERRONEOUS = 1 << 7; 1.8 - public static final int AMBIGUOUS = ERRONEOUS+1; // ambiguous reference 1.9 - public static final int HIDDEN = ERRONEOUS+2; // hidden method or field 1.10 - public static final int STATICERR = ERRONEOUS+3; // nonstatic member from static context 1.11 - public static final int MISSING_ENCL = ERRONEOUS+4; // missing enclosing class 1.12 - public static final int ABSENT_VAR = ERRONEOUS+5; // missing variable 1.13 - public static final int WRONG_MTHS = ERRONEOUS+6; // methods with wrong arguments 1.14 - public static final int WRONG_MTH = ERRONEOUS+7; // one method with wrong arguments 1.15 - public static final int ABSENT_MTH = ERRONEOUS+8; // missing method 1.16 - public static final int ABSENT_TYP = ERRONEOUS+9; // missing type 1.17 + public static final int ERRONEOUS = 1 << 7; 1.18 + public static final int AMBIGUOUS = ERRONEOUS + 1; // ambiguous reference 1.19 + public static final int HIDDEN = ERRONEOUS + 2; // hidden method or field 1.20 + public static final int STATICERR = ERRONEOUS + 3; // nonstatic member from static context 1.21 + public static final int MISSING_ENCL = ERRONEOUS + 4; // missing enclosing class 1.22 + public static final int ABSENT_VAR = ERRONEOUS + 5; // missing variable 1.23 + public static final int WRONG_MTHS = ERRONEOUS + 6; // methods with wrong arguments 1.24 + public static final int WRONG_MTH = ERRONEOUS + 7; // one method with wrong arguments 1.25 + public static final int ABSENT_MTH = ERRONEOUS + 8; // missing method 1.26 + public static final int ABSENT_TYP = ERRONEOUS + 9; // missing type 1.27 + public static final int WRONG_STATICNESS = ERRONEOUS + 10; // wrong staticness for method references 1.28 1.29 public enum KindName implements Formattable { 1.30 ANNOTATION("kindname.annotation"), 1.31 @@ -231,14 +232,14 @@ 1.32 return KindName.CLASS; 1.33 } 1.34 1.35 - /** A KindName representing the kind of a a missing symbol, given an 1.36 + /** A KindName representing the kind of a missing symbol, given an 1.37 * error kind. 1.38 * */ 1.39 public static KindName absentKind(int kind) { 1.40 switch (kind) { 1.41 case ABSENT_VAR: 1.42 return KindName.VAR; 1.43 - case WRONG_MTHS: case WRONG_MTH: case ABSENT_MTH: 1.44 + case WRONG_MTHS: case WRONG_MTH: case ABSENT_MTH: case WRONG_STATICNESS: 1.45 return KindName.METHOD; 1.46 case ABSENT_TYP: 1.47 return KindName.CLASS;
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Nov 14 13:47:38 2013 -0800 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Nov 15 11:08:12 2013 +0000 2.3 @@ -2697,9 +2697,10 @@ 2.4 Pair<Symbol, Resolve.ReferenceLookupHelper> refResult = null; 2.5 List<Type> saved_undet = resultInfo.checkContext.inferenceContext().save(); 2.6 try { 2.7 - refResult = rs.resolveMemberReference(that.pos(), localEnv, that, that.expr.type, 2.8 - that.name, argtypes, typeargtypes, true, referenceCheck, 2.9 - resultInfo.checkContext.inferenceContext()); 2.10 + refResult = rs.resolveMemberReference(localEnv, that, that.expr.type, 2.11 + that.name, argtypes, typeargtypes, referenceCheck, 2.12 + resultInfo.checkContext.inferenceContext(), 2.13 + resultInfo.checkContext.deferredAttrContext().mode); 2.14 } finally { 2.15 resultInfo.checkContext.inferenceContext().rollback(saved_undet); 2.16 } 2.17 @@ -2719,6 +2720,7 @@ 2.18 case HIDDEN: 2.19 case STATICERR: 2.20 case MISSING_ENCL: 2.21 + case WRONG_STATICNESS: 2.22 targetError = true; 2.23 break; 2.24 default: 2.25 @@ -2770,26 +2772,6 @@ 2.26 chk.checkRaw(that.expr, localEnv); 2.27 } 2.28 2.29 - if (!that.kind.isUnbound() && 2.30 - that.getMode() == ReferenceMode.INVOKE && 2.31 - TreeInfo.isStaticSelector(that.expr, names) && 2.32 - !that.sym.isStatic()) { 2.33 - log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()), 2.34 - diags.fragment("non-static.cant.be.ref", Kinds.kindName(refSym), refSym)); 2.35 - result = that.type = types.createErrorType(target); 2.36 - return; 2.37 - } 2.38 - 2.39 - if (that.kind.isUnbound() && 2.40 - that.getMode() == ReferenceMode.INVOKE && 2.41 - TreeInfo.isStaticSelector(that.expr, names) && 2.42 - that.sym.isStatic()) { 2.43 - log.error(that.expr.pos(), "invalid.mref", Kinds.kindName(that.getMode()), 2.44 - diags.fragment("static.method.in.unbound.lookup", Kinds.kindName(refSym), refSym)); 2.45 - result = that.type = types.createErrorType(target); 2.46 - return; 2.47 - } 2.48 - 2.49 if (that.sym.isStatic() && TreeInfo.isStaticSelector(that.expr, names) && 2.50 exprType.getTypeArguments().nonEmpty()) { 2.51 //static ref with class type-args
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Thu Nov 14 13:47:38 2013 -0800 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Fri Nov 15 11:08:12 2013 +0000 3.3 @@ -643,15 +643,16 @@ 3.4 } 3.5 JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree); 3.6 mref2.expr = exprTree; 3.7 - Pair<Symbol, ?> lookupRes = 3.8 - rs.resolveMemberReference(tree, localEnv, mref2, exprTree.type, 3.9 - tree.name, argtypes.toList(), null, true, rs.arityMethodCheck, inferenceContext); 3.10 - switch (lookupRes.fst.kind) { 3.11 + Symbol lookupSym = 3.12 + rs.resolveMemberReferenceByArity(localEnv, mref2, exprTree.type, 3.13 + tree.name, argtypes.toList(), inferenceContext); 3.14 + switch (lookupSym.kind) { 3.15 //note: as argtypes are erroneous types, type-errors must 3.16 //have been caused by arity mismatch 3.17 case Kinds.ABSENT_MTH: 3.18 case Kinds.WRONG_MTH: 3.19 case Kinds.WRONG_MTHS: 3.20 + case Kinds.WRONG_STATICNESS: 3.21 checkContext.report(tree, diags.fragment("incompatible.arg.types.in.mref")); 3.22 } 3.23 } 3.24 @@ -1037,11 +1038,10 @@ 3.25 attr.memberReferenceQualifierResult(tree)); 3.26 JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree); 3.27 mref2.expr = exprTree; 3.28 - Pair<Symbol, ReferenceLookupHelper> lookupRes = 3.29 - rs.resolveMemberReference(tree, localEnv, mref2, exprTree.type, 3.30 - tree.name, List.<Type>nil(), null, true, rs.nilMethodCheck, 3.31 - infer.emptyContext); 3.32 - Symbol res = tree.sym = lookupRes.fst; 3.33 + Symbol res = 3.34 + rs.getMemberReference(tree, localEnv, mref2, 3.35 + exprTree.type, tree.name); 3.36 + tree.sym = res; 3.37 if (res.kind >= Kinds.ERRONEOUS || 3.38 res.type.hasTag(FORALL) || 3.39 (res.flags() & Flags.VARARGS) != 0 ||
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Nov 14 13:47:38 2013 -0800 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Nov 15 11:08:12 2013 +0000 4.3 @@ -25,6 +25,7 @@ 4.4 4.5 package com.sun.tools.javac.comp; 4.6 4.7 +import com.sun.source.tree.MemberReferenceTree.ReferenceMode; 4.8 import com.sun.tools.javac.api.Formattable.LocalizedString; 4.9 import com.sun.tools.javac.code.*; 4.10 import com.sun.tools.javac.code.Symbol.*; 4.11 @@ -110,6 +111,9 @@ 4.12 SymbolNotFoundError(ABSENT_VAR); 4.13 methodNotFound = new 4.14 SymbolNotFoundError(ABSENT_MTH); 4.15 + methodWithCorrectStaticnessNotFound = new 4.16 + SymbolNotFoundError(WRONG_STATICNESS, 4.17 + "method found has incorrect staticness"); 4.18 typeNotFound = new 4.19 SymbolNotFoundError(ABSENT_TYP); 4.20 4.21 @@ -144,6 +148,7 @@ 4.22 */ 4.23 private final SymbolNotFoundError varNotFound; 4.24 private final SymbolNotFoundError methodNotFound; 4.25 + private final SymbolNotFoundError methodWithCorrectStaticnessNotFound; 4.26 private final SymbolNotFoundError typeNotFound; 4.27 4.28 public static Resolve instance(Context context) { 4.29 @@ -868,6 +873,12 @@ 4.30 } 4.31 }; 4.32 4.33 + /** 4.34 + * This class handles method reference applicability checks; since during 4.35 + * these checks it's sometime possible to have inference variables on 4.36 + * the actual argument types list, the method applicability check must be 4.37 + * extended so that inference variables are 'opened' as needed. 4.38 + */ 4.39 class MethodReferenceCheck extends AbstractMethodCheck { 4.40 4.41 InferenceContext pendingInferenceContext; 4.42 @@ -2674,6 +2685,97 @@ 4.43 return resolveOperator(pos, optag, env, List.of(left, right)); 4.44 } 4.45 4.46 + Symbol getMemberReference(DiagnosticPosition pos, 4.47 + Env<AttrContext> env, 4.48 + JCMemberReference referenceTree, 4.49 + Type site, 4.50 + Name name) { 4.51 + 4.52 + site = types.capture(site); 4.53 + 4.54 + ReferenceLookupHelper lookupHelper = makeReferenceLookupHelper( 4.55 + referenceTree, site, name, List.<Type>nil(), null, VARARITY); 4.56 + 4.57 + Env<AttrContext> newEnv = env.dup(env.tree, env.info.dup()); 4.58 + Symbol sym = lookupMethod(newEnv, env.tree.pos(), site.tsym, 4.59 + nilMethodCheck, lookupHelper); 4.60 + 4.61 + env.info.pendingResolutionPhase = newEnv.info.pendingResolutionPhase; 4.62 + 4.63 + return sym; 4.64 + } 4.65 + 4.66 + ReferenceLookupHelper makeReferenceLookupHelper(JCMemberReference referenceTree, 4.67 + Type site, 4.68 + Name name, 4.69 + List<Type> argtypes, 4.70 + List<Type> typeargtypes, 4.71 + MethodResolutionPhase maxPhase) { 4.72 + ReferenceLookupHelper result; 4.73 + if (!name.equals(names.init)) { 4.74 + //method reference 4.75 + result = 4.76 + new MethodReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, maxPhase); 4.77 + } else { 4.78 + if (site.hasTag(ARRAY)) { 4.79 + //array constructor reference 4.80 + result = 4.81 + new ArrayConstructorReferenceLookupHelper(referenceTree, site, argtypes, typeargtypes, maxPhase); 4.82 + } else { 4.83 + //class constructor reference 4.84 + result = 4.85 + new ConstructorReferenceLookupHelper(referenceTree, site, argtypes, typeargtypes, maxPhase); 4.86 + } 4.87 + } 4.88 + return result; 4.89 + } 4.90 + 4.91 + Symbol resolveMemberReferenceByArity(Env<AttrContext> env, 4.92 + JCMemberReference referenceTree, 4.93 + Type site, 4.94 + Name name, 4.95 + List<Type> argtypes, 4.96 + InferenceContext inferenceContext) { 4.97 + 4.98 + boolean isStaticSelector = TreeInfo.isStaticSelector(referenceTree.expr, names); 4.99 + site = types.capture(site); 4.100 + 4.101 + ReferenceLookupHelper boundLookupHelper = makeReferenceLookupHelper( 4.102 + referenceTree, site, name, argtypes, null, VARARITY); 4.103 + //step 1 - bound lookup 4.104 + Env<AttrContext> boundEnv = env.dup(env.tree, env.info.dup()); 4.105 + Symbol boundSym = lookupMethod(boundEnv, env.tree.pos(), site.tsym, 4.106 + arityMethodCheck, boundLookupHelper); 4.107 + if (isStaticSelector && 4.108 + !name.equals(names.init) && 4.109 + !boundSym.isStatic() && 4.110 + boundSym.kind < ERRONEOUS) { 4.111 + boundSym = methodNotFound; 4.112 + } 4.113 + 4.114 + //step 2 - unbound lookup 4.115 + Symbol unboundSym = methodNotFound; 4.116 + ReferenceLookupHelper unboundLookupHelper = null; 4.117 + Env<AttrContext> unboundEnv = env.dup(env.tree, env.info.dup()); 4.118 + if (isStaticSelector) { 4.119 + unboundLookupHelper = boundLookupHelper.unboundLookup(inferenceContext); 4.120 + unboundSym = lookupMethod(unboundEnv, env.tree.pos(), site.tsym, 4.121 + arityMethodCheck, unboundLookupHelper); 4.122 + if (unboundSym.isStatic() && 4.123 + unboundSym.kind < ERRONEOUS) { 4.124 + unboundSym = methodNotFound; 4.125 + } 4.126 + } 4.127 + 4.128 + //merge results 4.129 + Symbol bestSym = choose(boundSym, unboundSym); 4.130 + env.info.pendingResolutionPhase = bestSym == unboundSym ? 4.131 + unboundEnv.info.pendingResolutionPhase : 4.132 + boundEnv.info.pendingResolutionPhase; 4.133 + 4.134 + return bestSym; 4.135 + } 4.136 + 4.137 /** 4.138 * Resolution of member references is typically done as a single 4.139 * overload resolution step, where the argument types A are inferred from 4.140 @@ -2700,47 +2802,118 @@ 4.141 * the type T might be dynamically inferred (i.e. if constructor reference 4.142 * has a raw qualifier). 4.143 */ 4.144 - Pair<Symbol, ReferenceLookupHelper> resolveMemberReference(DiagnosticPosition pos, 4.145 - Env<AttrContext> env, 4.146 + Pair<Symbol, ReferenceLookupHelper> resolveMemberReference(Env<AttrContext> env, 4.147 JCMemberReference referenceTree, 4.148 Type site, 4.149 - Name name, List<Type> argtypes, 4.150 + Name name, 4.151 + List<Type> argtypes, 4.152 List<Type> typeargtypes, 4.153 - boolean boxingAllowed, 4.154 MethodCheck methodCheck, 4.155 - InferenceContext inferenceContext) { 4.156 - MethodResolutionPhase maxPhase = boxingAllowed ? VARARITY : BASIC; 4.157 + InferenceContext inferenceContext, 4.158 + AttrMode mode) { 4.159 4.160 site = types.capture(site); 4.161 - 4.162 - ReferenceLookupHelper boundLookupHelper; 4.163 - if (!name.equals(names.init)) { 4.164 - //method reference 4.165 - boundLookupHelper = 4.166 - new MethodReferenceLookupHelper(referenceTree, name, site, argtypes, typeargtypes, maxPhase); 4.167 - } else if (site.hasTag(ARRAY)) { 4.168 - //array constructor reference 4.169 - boundLookupHelper = 4.170 - new ArrayConstructorReferenceLookupHelper(referenceTree, site, argtypes, typeargtypes, maxPhase); 4.171 - } else { 4.172 - //class constructor reference 4.173 - boundLookupHelper = 4.174 - new ConstructorReferenceLookupHelper(referenceTree, site, argtypes, typeargtypes, maxPhase); 4.175 - } 4.176 + ReferenceLookupHelper boundLookupHelper = makeReferenceLookupHelper( 4.177 + referenceTree, site, name, argtypes, typeargtypes, VARARITY); 4.178 4.179 //step 1 - bound lookup 4.180 Env<AttrContext> boundEnv = env.dup(env.tree, env.info.dup()); 4.181 - Symbol boundSym = lookupMethod(boundEnv, env.tree.pos(), site.tsym, methodCheck, boundLookupHelper); 4.182 + Symbol origBoundSym; 4.183 + boolean staticErrorForBound = false; 4.184 + MethodResolutionContext boundSearchResolveContext = new MethodResolutionContext(); 4.185 + boundSearchResolveContext.methodCheck = methodCheck; 4.186 + Symbol boundSym = origBoundSym = lookupMethod(boundEnv, env.tree.pos(), 4.187 + site.tsym, boundSearchResolveContext, boundLookupHelper); 4.188 + SearchResultKind boundSearchResultKind = SearchResultKind.NOT_APPLICABLE_MATCH; 4.189 + boolean isStaticSelector = TreeInfo.isStaticSelector(referenceTree.expr, names); 4.190 + boolean shouldCheckForStaticness = isStaticSelector && 4.191 + referenceTree.getMode() == ReferenceMode.INVOKE; 4.192 + if (boundSym.kind != WRONG_MTHS && boundSym.kind != WRONG_MTH) { 4.193 + if (shouldCheckForStaticness) { 4.194 + if (!boundSym.isStatic()) { 4.195 + staticErrorForBound = true; 4.196 + if (hasAnotherApplicableMethod( 4.197 + boundSearchResolveContext, boundSym, true)) { 4.198 + boundSearchResultKind = SearchResultKind.BAD_MATCH_MORE_SPECIFIC; 4.199 + } else { 4.200 + boundSearchResultKind = SearchResultKind.BAD_MATCH; 4.201 + if (boundSym.kind < ERRONEOUS) { 4.202 + boundSym = methodWithCorrectStaticnessNotFound; 4.203 + } 4.204 + } 4.205 + } else if (boundSym.kind < ERRONEOUS) { 4.206 + boundSearchResultKind = SearchResultKind.GOOD_MATCH; 4.207 + } 4.208 + } 4.209 + } 4.210 4.211 //step 2 - unbound lookup 4.212 - ReferenceLookupHelper unboundLookupHelper = boundLookupHelper.unboundLookup(inferenceContext); 4.213 + Symbol origUnboundSym = null; 4.214 + Symbol unboundSym = methodNotFound; 4.215 + ReferenceLookupHelper unboundLookupHelper = null; 4.216 Env<AttrContext> unboundEnv = env.dup(env.tree, env.info.dup()); 4.217 - Symbol unboundSym = lookupMethod(unboundEnv, env.tree.pos(), site.tsym, methodCheck, unboundLookupHelper); 4.218 + SearchResultKind unboundSearchResultKind = SearchResultKind.NOT_APPLICABLE_MATCH; 4.219 + boolean staticErrorForUnbound = false; 4.220 + if (isStaticSelector) { 4.221 + unboundLookupHelper = boundLookupHelper.unboundLookup(inferenceContext); 4.222 + MethodResolutionContext unboundSearchResolveContext = 4.223 + new MethodResolutionContext(); 4.224 + unboundSearchResolveContext.methodCheck = methodCheck; 4.225 + unboundSym = origUnboundSym = lookupMethod(unboundEnv, env.tree.pos(), 4.226 + site.tsym, unboundSearchResolveContext, unboundLookupHelper); 4.227 + 4.228 + if (unboundSym.kind != WRONG_MTH && unboundSym.kind != WRONG_MTHS) { 4.229 + if (shouldCheckForStaticness) { 4.230 + if (unboundSym.isStatic()) { 4.231 + staticErrorForUnbound = true; 4.232 + if (hasAnotherApplicableMethod( 4.233 + unboundSearchResolveContext, unboundSym, false)) { 4.234 + unboundSearchResultKind = SearchResultKind.BAD_MATCH_MORE_SPECIFIC; 4.235 + } else { 4.236 + unboundSearchResultKind = SearchResultKind.BAD_MATCH; 4.237 + if (unboundSym.kind < ERRONEOUS) { 4.238 + unboundSym = methodWithCorrectStaticnessNotFound; 4.239 + } 4.240 + } 4.241 + } else if (unboundSym.kind < ERRONEOUS) { 4.242 + unboundSearchResultKind = SearchResultKind.GOOD_MATCH; 4.243 + } 4.244 + } 4.245 + } 4.246 + } 4.247 4.248 //merge results 4.249 Pair<Symbol, ReferenceLookupHelper> res; 4.250 Symbol bestSym = choose(boundSym, unboundSym); 4.251 - res = new Pair<Symbol, ReferenceLookupHelper>(bestSym, 4.252 + if (bestSym.kind < ERRONEOUS && (staticErrorForBound || staticErrorForUnbound)) { 4.253 + if (staticErrorForBound) { 4.254 + boundSym = methodWithCorrectStaticnessNotFound; 4.255 + } 4.256 + if (staticErrorForUnbound) { 4.257 + unboundSym = methodWithCorrectStaticnessNotFound; 4.258 + } 4.259 + bestSym = choose(boundSym, unboundSym); 4.260 + } 4.261 + if (bestSym == methodWithCorrectStaticnessNotFound && mode == AttrMode.CHECK) { 4.262 + Symbol symToPrint = origBoundSym; 4.263 + String errorFragmentToPrint = "non-static.cant.be.ref"; 4.264 + if (staticErrorForBound && staticErrorForUnbound) { 4.265 + if (unboundSearchResultKind == SearchResultKind.BAD_MATCH_MORE_SPECIFIC) { 4.266 + symToPrint = origUnboundSym; 4.267 + errorFragmentToPrint = "static.method.in.unbound.lookup"; 4.268 + } 4.269 + } else { 4.270 + if (!staticErrorForBound) { 4.271 + symToPrint = origUnboundSym; 4.272 + errorFragmentToPrint = "static.method.in.unbound.lookup"; 4.273 + } 4.274 + } 4.275 + log.error(referenceTree.expr.pos(), "invalid.mref", 4.276 + Kinds.kindName(referenceTree.getMode()), 4.277 + diags.fragment(errorFragmentToPrint, 4.278 + Kinds.kindName(symToPrint), symToPrint)); 4.279 + } 4.280 + res = new Pair<>(bestSym, 4.281 bestSym == unboundSym ? unboundLookupHelper : boundLookupHelper); 4.282 env.info.pendingResolutionPhase = bestSym == unboundSym ? 4.283 unboundEnv.info.pendingResolutionPhase : 4.284 @@ -2748,18 +2921,42 @@ 4.285 4.286 return res; 4.287 } 4.288 + 4.289 + enum SearchResultKind { 4.290 + GOOD_MATCH, //type I 4.291 + BAD_MATCH_MORE_SPECIFIC, //type II 4.292 + BAD_MATCH, //type III 4.293 + NOT_APPLICABLE_MATCH //type IV 4.294 + } 4.295 + 4.296 + boolean hasAnotherApplicableMethod(MethodResolutionContext resolutionContext, 4.297 + Symbol bestSoFar, boolean staticMth) { 4.298 + for (Candidate c : resolutionContext.candidates) { 4.299 + if (resolutionContext.step != c.step || 4.300 + !c.isApplicable() || 4.301 + c.sym == bestSoFar) { 4.302 + continue; 4.303 + } else { 4.304 + if (c.sym.isStatic() == staticMth) { 4.305 + return true; 4.306 + } 4.307 + } 4.308 + } 4.309 + return false; 4.310 + } 4.311 + 4.312 //where 4.313 - private Symbol choose(Symbol s1, Symbol s2) { 4.314 - if (lookupSuccess(s1) && lookupSuccess(s2)) { 4.315 - return ambiguityError(s1, s2); 4.316 - } else if (lookupSuccess(s1) || 4.317 - (canIgnore(s2) && !canIgnore(s1))) { 4.318 - return s1; 4.319 - } else if (lookupSuccess(s2) || 4.320 - (canIgnore(s1) && !canIgnore(s2))) { 4.321 - return s2; 4.322 + private Symbol choose(Symbol boundSym, Symbol unboundSym) { 4.323 + if (lookupSuccess(boundSym) && lookupSuccess(unboundSym)) { 4.324 + return ambiguityError(boundSym, unboundSym); 4.325 + } else if (lookupSuccess(boundSym) || 4.326 + (canIgnore(unboundSym) && !canIgnore(boundSym))) { 4.327 + return boundSym; 4.328 + } else if (lookupSuccess(unboundSym) || 4.329 + (canIgnore(boundSym) && !canIgnore(unboundSym))) { 4.330 + return unboundSym; 4.331 } else { 4.332 - return s1; 4.333 + return boundSym; 4.334 } 4.335 } 4.336 4.337 @@ -2780,6 +2977,8 @@ 4.338 InapplicableSymbolsError errSyms = 4.339 (InapplicableSymbolsError)s; 4.340 return errSyms.filterCandidates(errSyms.mapCandidates()).isEmpty(); 4.341 + case WRONG_STATICNESS: 4.342 + return false; 4.343 default: 4.344 return false; 4.345 } 4.346 @@ -2894,7 +3093,6 @@ 4.347 List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) { 4.348 super(name, site, argtypes, typeargtypes, maxPhase); 4.349 this.referenceTree = referenceTree; 4.350 - 4.351 } 4.352 4.353 /** 4.354 @@ -3324,6 +3522,11 @@ 4.355 return false; 4.356 } 4.357 4.358 + @Override 4.359 + public boolean isStatic() { 4.360 + return false; 4.361 + } 4.362 + 4.363 /** 4.364 * Create an external representation for this erroneous symbol to be 4.365 * used during attribution - by default this returns the symbol of a 4.366 @@ -3398,7 +3601,11 @@ 4.367 class SymbolNotFoundError extends ResolveError { 4.368 4.369 SymbolNotFoundError(int kind) { 4.370 - super(kind, "symbol not found error"); 4.371 + this(kind, "symbol not found error"); 4.372 + } 4.373 + 4.374 + SymbolNotFoundError(int kind, String debugName) { 4.375 + super(kind, debugName); 4.376 } 4.377 4.378 @Override 4.379 @@ -3436,7 +3643,8 @@ 4.380 hasLocation = !location.name.equals(names._this) && 4.381 !location.name.equals(names._super); 4.382 } 4.383 - boolean isConstructor = kind == ABSENT_MTH && name == names.init; 4.384 + boolean isConstructor = (kind == ABSENT_MTH || kind == WRONG_STATICNESS) && 4.385 + name == names.init; 4.386 KindName kindname = isConstructor ? KindName.CONSTRUCTOR : absentKind(kind); 4.387 Name idname = isConstructor ? site.tsym.name : name; 4.388 String errKey = getErrorKey(kindname, typeargtypes.nonEmpty(), hasLocation);
5.1 --- a/test/tools/javac/lambda/MethodReference22.java Thu Nov 14 13:47:38 2013 -0800 5.2 +++ b/test/tools/javac/lambda/MethodReference22.java Fri Nov 15 11:08:12 2013 +0000 5.3 @@ -48,19 +48,19 @@ 5.4 } 5.5 5.6 static void test2() { 5.7 - SAM2 s1 = MethodReference22::m1; //ambiguous 5.8 - call2(MethodReference22::m1); //ambiguous 5.9 - SAM2 s2 = MethodReference22::m2; //ambiguous 5.10 - call2(MethodReference22::m2); //ambiguous 5.11 - SAM2 s3 = MethodReference22::m3; //ambiguous 5.12 - call2(MethodReference22::m3); //ambiguous 5.13 - SAM2 s4 = MethodReference22::m4; //ambiguous 5.14 - call2(MethodReference22::m4); //ambiguous 5.15 + SAM2 s1 = MethodReference22::m1; //ok 5.16 + call2(MethodReference22::m1); //ok 5.17 + SAM2 s2 = MethodReference22::m2; //ok 5.18 + call2(MethodReference22::m2); //ok 5.19 + SAM2 s3 = MethodReference22::m3; //fail 5.20 + call2(MethodReference22::m3); //fail 5.21 + SAM2 s4 = MethodReference22::m4; //fail 5.22 + call2(MethodReference22::m4); //fail 5.23 } 5.24 5.25 static void test3() { 5.26 - call3(MethodReference22::m1); //fail 5.27 - call3(MethodReference22::m2); //ok 5.28 + call3(MethodReference22::m1); //ok 5.29 + call3(MethodReference22::m2); //ambiguous 5.30 call3(MethodReference22::m3); //ok 5.31 call3(MethodReference22::m4); //fail 5.32 }
6.1 --- a/test/tools/javac/lambda/MethodReference22.out Thu Nov 14 13:47:38 2013 -0800 6.2 +++ b/test/tools/javac/lambda/MethodReference22.out Fri Nov 15 11:08:12 2013 +0000 6.3 @@ -1,19 +1,11 @@ 6.4 MethodReference22.java:40:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String)) 6.5 -MethodReference22.java:41:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String)) 6.6 +MethodReference22.java:41:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @999, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.mref)) 6.7 MethodReference22.java:46:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)) 6.8 -MethodReference22.java:47:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)) 6.9 -MethodReference22.java:51:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m1, kindname.method, m1(MethodReference22,java.lang.String), MethodReference22, kindname.method, m1(java.lang.String), MethodReference22)) 6.10 -MethodReference22.java:52:14: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1401, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m1, kindname.method, m1(MethodReference22,java.lang.String), MethodReference22, kindname.method, m1(java.lang.String), MethodReference22))) 6.11 -MethodReference22.java:53:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m2, kindname.method, m2(MethodReference22,java.lang.String), MethodReference22, kindname.method, m2(java.lang.String), MethodReference22)) 6.12 -MethodReference22.java:54:14: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1504, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m2, kindname.method, m2(MethodReference22,java.lang.String), MethodReference22, kindname.method, m2(java.lang.String), MethodReference22))) 6.13 -MethodReference22.java:55:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m3, kindname.method, m3(MethodReference22,java.lang.String), MethodReference22, kindname.method, m3(java.lang.String), MethodReference22)) 6.14 -MethodReference22.java:56:14: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1607, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m3, kindname.method, m3(MethodReference22,java.lang.String), MethodReference22, kindname.method, m3(java.lang.String), MethodReference22))) 6.15 +MethodReference22.java:47:9: compiler.err.cant.apply.symbol: kindname.method, call1, MethodReference22.SAM1, @1270, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.mref)) 6.16 +MethodReference22.java:55:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m3(MethodReference22,java.lang.String)) 6.17 +MethodReference22.java:56:9: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1574, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.incompatible.arg.types.in.mref)) 6.18 MethodReference22.java:57:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22)) 6.19 -MethodReference22.java:58:14: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1710, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))) 6.20 -MethodReference22.java:62:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22 6.21 -MethodReference22.java:62:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m1(java.lang.String)) 6.22 +MethodReference22.java:58:14: compiler.err.cant.apply.symbol: kindname.method, call2, MethodReference22.SAM2, @1667, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))) 6.23 MethodReference22.java:63:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22 6.24 -MethodReference22.java:64:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22 6.25 -MethodReference22.java:65:9: compiler.err.ref.ambiguous: call3, kindname.method, call3(MethodReference22.SAM1), MethodReference22, kindname.method, call3(MethodReference22.SAM2), MethodReference22 6.26 -MethodReference22.java:65:15: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m4(java.lang.String)) 6.27 -18 errors 6.28 +MethodReference22.java:65:14: compiler.err.cant.apply.symbol: kindname.method, call3, MethodReference22.SAM2, @1881, kindname.class, MethodReference22, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference22,java.lang.String), MethodReference22, kindname.method, m4(java.lang.String), MethodReference22))) 6.29 +10 errors
7.1 --- a/test/tools/javac/lambda/MethodReference51.java Thu Nov 14 13:47:38 2013 -0800 7.2 +++ b/test/tools/javac/lambda/MethodReference51.java Fri Nov 15 11:08:12 2013 +0000 7.3 @@ -36,11 +36,11 @@ 7.4 7.5 7.6 static void test() { 7.7 - IntSam s1 = MethodReference51::unknown; //method not found 7.8 - IntSam s2 = MethodReference51::f; //inapplicable method 7.9 - IntSam s3 = MethodReference51::g; //inapplicable methods 7.10 - IntegerIntegerSam s4 = MethodReference51::g; //ambiguous 7.11 - IntSam s5 = MethodReference51::h; //static error 7.12 - IntSam s6 = MethodReference51.foo::j; //inaccessible method 7.13 + IntSam s1 = MethodReference51::unknown; //fail 7.14 + IntSam s2 = MethodReference51::f; //fail 7.15 + IntSam s3 = MethodReference51::g; //fail 7.16 + IntegerIntegerSam s4 = MethodReference51::g; //fail 7.17 + IntSam s5 = MethodReference51::h; //fail 7.18 + IntSam s6 = MethodReference51.foo::j; //fail 7.19 } 7.20 }
8.1 --- a/test/tools/javac/lambda/MethodReference68.out Thu Nov 14 13:47:38 2013 -0800 8.2 +++ b/test/tools/javac/lambda/MethodReference68.out Fri Nov 15 11:08:12 2013 +0000 8.3 @@ -1,2 +1,3 @@ 8.4 MethodReference68.java:21:10: compiler.err.cant.apply.symbol: kindname.method, g, MethodReference68.F<Z>,Z[], @493,int, kindname.class, MethodReference68, (compiler.misc.inferred.do.not.conform.to.upper.bounds: java.lang.Integer, MethodReference68.Foo,java.lang.Object) 8.5 -1 error 8.6 +MethodReference68.java:21:12: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, getName()) 8.7 +2 errors
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/tools/javac/lambda/MethodReference73.java Fri Nov 15 11:08:12 2013 +0000 9.3 @@ -0,0 +1,110 @@ 9.4 +/* 9.5 + * @test /nodynamiccopyright/ 9.6 + * @bug 8026231 9.7 + * @summary Look at 'static' flag when checking method references 9.8 + * @compile/fail/ref=MethodReference73.out -XDrawDiagnostics MethodReference73.java 9.9 + */ 9.10 + 9.11 +public class MethodReference73 { 9.12 + 9.13 + interface SAM { 9.14 + void m(MethodReference73 rec, String x); 9.15 + } 9.16 + 9.17 + void m1(MethodReference73 rec, String x) {} 9.18 + static void m1(MethodReference73 rec, Object x) {} 9.19 + void m1(String x) {} 9.20 + 9.21 + static void m2(MethodReference73 rec, String x) {} 9.22 + void m2(Object x) {} 9.23 + static void m2(String x) {} 9.24 + 9.25 + static void m3(MethodReference73 rec, String x) {} 9.26 + void m3(String x) {} 9.27 + 9.28 + void m4(MethodReference73 rec, String x) {} 9.29 + static void m4(MethodReference73 rec, Object x) {} 9.30 + static void m4(String x) {} 9.31 + void m4(Object x) {} 9.32 + 9.33 + static void m5(MethodReference73 rec, String x) {} 9.34 + static void m5(String x) {} 9.35 + 9.36 + static void m6(MethodReference73 rec, String x) {} 9.37 + void m6(String x, int i) {} 9.38 + 9.39 + void m7(MethodReference73 rec, String x) {} 9.40 + void m7(String x) {} 9.41 + 9.42 + static void m8(MethodReference73 rec, String x, int i) {} 9.43 + void m8(String x) {} 9.44 + 9.45 + void m9(MethodReference73 rec, String x) {} 9.46 + static void m9(MethodReference73 rec, Object x) {} 9.47 + static void m9(String x) {} 9.48 + 9.49 + void m10(MethodReference73 rec, String x) {} 9.50 + static void m10(MethodReference73 rec, Object x) {} 9.51 + void m10(String x, int i) {} 9.52 + 9.53 + void m11(MethodReference73 rec, String x) {} 9.54 + void m11(Object x) {} 9.55 + static void m11(String x) {} 9.56 + 9.57 + static void m12(MethodReference73 rec, String x, int i) {} 9.58 + void m12(Object x) {} 9.59 + static void m12(String x) {} 9.60 + 9.61 + void m13(MethodReference73 rec, String x) {} 9.62 + void m13(String x, int i) {} 9.63 + 9.64 + static void m14(MethodReference73 rec, String x, int i) {} 9.65 + static void m14(String x) {} 9.66 + 9.67 + void m15(MethodReference73 rec, String x) {} 9.68 + static void m15(String x) {} 9.69 + 9.70 + static void m16(MethodReference73 rec, String x, int i) {} 9.71 + void m16(String x, int i) {} 9.72 + 9.73 + /** For method references with a type selector two searches are performed. 9.74 + * Each of them may yield one of the following results: 9.75 + * I) a good match 9.76 + * II) a bad match more specific than a good match 9.77 + * III) a bad match with no good matches 9.78 + * IV) no applicable method found 9.79 + * 9.80 + * Whether a match is considered to be good or not depends on the staticness 9.81 + * of the matched method. The expected result of the first search is a static 9.82 + * method. The expected result of the second search is an instance method. 9.83 + * 9.84 + * If the most specific method has the wrong staticness but there is an 9.85 + * applicable method with the right staticness then we have the (II) case. 9.86 + * The (III) case is reserved for those cases when the most specific method 9.87 + * has the wrong staticness but there is no applicable method with the right 9.88 + * staticness. 9.89 + */ 9.90 + 9.91 + static void test() { 9.92 + SAM s1 = MethodReference73::m1; //(II, I) ambiguous 9.93 + SAM s2 = MethodReference73::m2; //(I, II) ambiguous 9.94 + SAM s3 = MethodReference73::m3; //(I, I) ambiguous 9.95 + SAM s4 = MethodReference73::m4; //(II, II) ambiguous 9.96 + 9.97 + SAM s5 = MethodReference73::m5; //(I, III) first search's result gets selected 9.98 + SAM s6 = MethodReference73::m6; //(I, IV) first search's result gets selected 9.99 + 9.100 + SAM s7 = MethodReference73::m7; //(III, I) second search's result gets selected 9.101 + SAM s8 = MethodReference73::m8; //(IV, I) second search's result gets selected 9.102 + 9.103 + SAM s9 = MethodReference73::m9; //(II, III) method matched by first search has the wrong staticness 9.104 + SAM s10 = MethodReference73::m10; //(II, IV) method matched by first search has the wrong staticness 9.105 + SAM s11 = MethodReference73::m11; //(III, II) method matched by second search has the wrong staticness 9.106 + SAM s12 = MethodReference73::m12; //(IV, II) method matched by second search has the wrong staticness 9.107 + SAM s13 = MethodReference73::m13; //(III, IV) method matched by first search has the wrong staticness 9.108 + SAM s14 = MethodReference73::m14; //(IV, III) method matched by second search has the wrong staticness 9.109 + SAM s15 = MethodReference73::m15; //(III, III) method matched by first search has the wrong staticness 9.110 + 9.111 + SAM s16 = MethodReference73::m16; //(IV, IV) incompatible types, invalid method reference 9.112 + } 9.113 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/tools/javac/lambda/MethodReference73.out Fri Nov 15 11:08:12 2013 +0000 10.3 @@ -0,0 +1,13 @@ 10.4 +MethodReference73.java:89:18: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m1, kindname.method, m1(MethodReference73,java.lang.String), MethodReference73, kindname.method, m1(java.lang.String), MethodReference73)) 10.5 +MethodReference73.java:90:18: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m2, kindname.method, m2(MethodReference73,java.lang.String), MethodReference73, kindname.method, m2(java.lang.String), MethodReference73)) 10.6 +MethodReference73.java:91:18: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m3, kindname.method, m3(MethodReference73,java.lang.String), MethodReference73, kindname.method, m3(java.lang.String), MethodReference73)) 10.7 +MethodReference73.java:92:18: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.ref.ambiguous: m4, kindname.method, m4(MethodReference73,java.lang.String), MethodReference73, kindname.method, m4(java.lang.String), MethodReference73)) 10.8 +MethodReference73.java:100:18: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m9(MethodReference73,java.lang.String)) 10.9 +MethodReference73.java:101:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m10(MethodReference73,java.lang.String)) 10.10 +MethodReference73.java:102:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.static.method.in.unbound.lookup: kindname.method, m11(java.lang.String)) 10.11 +MethodReference73.java:103:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.static.method.in.unbound.lookup: kindname.method, m12(java.lang.String)) 10.12 +MethodReference73.java:104:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m13(MethodReference73,java.lang.String)) 10.13 +MethodReference73.java:105:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.static.method.in.unbound.lookup: kindname.method, m14(java.lang.String)) 10.14 +MethodReference73.java:106:19: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, m15(MethodReference73,java.lang.String)) 10.15 +MethodReference73.java:108:19: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbols: kindname.method, m16, MethodReference73,java.lang.String,{(compiler.misc.inapplicable.method: kindname.method, MethodReference73, m16(MethodReference73,java.lang.String,int), (compiler.misc.arg.length.mismatch)),(compiler.misc.inapplicable.method: kindname.method, MethodReference73, m16(java.lang.String,int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: MethodReference73, java.lang.String)))})) 10.16 +12 errors
11.1 --- a/test/tools/javac/lambda/TargetType60.java Thu Nov 14 13:47:38 2013 -0800 11.2 +++ b/test/tools/javac/lambda/TargetType60.java Fri Nov 15 11:08:12 2013 +0000 11.3 @@ -57,7 +57,7 @@ 11.4 11.5 static void testUnbound() { 11.6 TargetType60 s1 = u(TargetType60::n0); //ok - resolves to u(Sam1) 11.7 - TargetType60 s2 = u(TargetType60::n1); //ambiguous (u(Sam1), u(Sam2) apply) 11.8 + TargetType60 s2 = u(TargetType60::n1); //ok - resolves to u(Sam2) 11.9 TargetType60 s3 = u(TargetType60::n2); //none is applicable 11.10 TargetType60 s4 = u(TargetType60::n01);//ambiguous (u(Sam1), u(Sam2) apply) 11.11 TargetType60 s5 = u(TargetType60::n012);//ambiguous (u(Sam1), u(Sam2) apply)
12.1 --- a/test/tools/javac/lambda/TargetType60.out Thu Nov 14 13:47:38 2013 -0800 12.2 +++ b/test/tools/javac/lambda/TargetType60.out Fri Nov 15 11:08:12 2013 +0000 12.3 @@ -1,8 +1,6 @@ 12.4 TargetType60.java:54:21: compiler.err.ref.ambiguous: g, kindname.method, g(TargetType60.Sam0), TargetType60, kindname.method, <U>g(TargetType60.Sam1<U>), TargetType60 12.5 TargetType60.java:55:21: compiler.err.ref.ambiguous: g, kindname.method, <U>g(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>g(TargetType60.Sam2<U,java.lang.String>), TargetType60 12.6 -TargetType60.java:60:27: compiler.err.ref.ambiguous: u, kindname.method, <U>u(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>u(TargetType60.Sam2<U,java.lang.String>), TargetType60 12.7 -TargetType60.java:60:29: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, n1(java.lang.String)) 12.8 -TargetType60.java:61:29: compiler.err.invalid.mref: kindname.method, (compiler.misc.non-static.cant.be.ref: kindname.method, n2(TargetType60,java.lang.String)) 12.9 +TargetType60.java:61:27: compiler.err.cant.apply.symbols: kindname.method, u, @1639,{(compiler.misc.inapplicable.method: kindname.method, TargetType60, <U>u(TargetType60.Sam1<U>), (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.apply.symbol: kindname.method, n2, TargetType60,java.lang.String, U, kindname.class, TargetType60, (compiler.misc.arg.length.mismatch))))),(compiler.misc.inapplicable.method: kindname.method, TargetType60, <U>u(TargetType60.Sam2<U,java.lang.String>), (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.invalid.mref: kindname.method, (compiler.misc.cant.resolve.location.args: kindname.method, n2, , U,java.lang.String, (compiler.misc.location: kindname.class, TargetType60, null)))))} 12.10 TargetType60.java:62:27: compiler.err.ref.ambiguous: u, kindname.method, <U>u(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>u(TargetType60.Sam2<U,java.lang.String>), TargetType60 12.11 TargetType60.java:63:27: compiler.err.ref.ambiguous: u, kindname.method, <U>u(TargetType60.Sam1<U>), TargetType60, kindname.method, <U>u(TargetType60.Sam2<U,java.lang.String>), TargetType60 12.12 -7 errors 12.13 +5 errors