Mon, 08 Apr 2013 15:51:41 +0100
8010922: Cleanup: add support for ad-hoc method check logic
Summary: Support pluggable method checkers
Reviewed-by: jjg
1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Apr 05 14:51:55 2013 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Apr 08 15:51:41 2013 +0100 1.3 @@ -2574,8 +2574,9 @@ 1.4 setFunctionalInfo(that, pt(), desc, resultInfo.checkContext.inferenceContext()); 1.5 List<Type> argtypes = desc.getParameterTypes(); 1.6 1.7 - Pair<Symbol, Resolve.ReferenceLookupHelper> refResult = rs.resolveMemberReference(that.pos(), localEnv, that, 1.8 - that.expr.type, that.name, argtypes, typeargtypes, true); 1.9 + Pair<Symbol, Resolve.ReferenceLookupHelper> refResult = 1.10 + rs.resolveMemberReference(that.pos(), localEnv, that, 1.11 + that.expr.type, that.name, argtypes, typeargtypes, true, rs.resolveMethodCheck); 1.12 1.13 Symbol refSym = refResult.fst; 1.14 Resolve.ReferenceLookupHelper lookupHelper = refResult.snd;
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Fri Apr 05 14:51:55 2013 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Mon Apr 08 15:51:41 2013 +0100 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -28,6 +28,7 @@ 2.11 import com.sun.tools.javac.code.*; 2.12 import com.sun.tools.javac.tree.*; 2.13 import com.sun.tools.javac.util.*; 2.14 +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; 2.15 import com.sun.tools.javac.code.Symbol.*; 2.16 import com.sun.tools.javac.code.Type.*; 2.17 import com.sun.tools.javac.comp.Attr.ResultInfo; 2.18 @@ -531,12 +532,13 @@ 2.19 attr.memberReferenceQualifierResult(tree)); 2.20 ListBuffer<Type> argtypes = ListBuffer.lb(); 2.21 for (Type t : types.findDescriptorType(pt).getParameterTypes()) { 2.22 - argtypes.append(syms.errType); 2.23 + argtypes.append(Type.noType); 2.24 } 2.25 JCMemberReference mref2 = new TreeCopier<Void>(make).copy(tree); 2.26 mref2.expr = exprTree; 2.27 Pair<Symbol, ?> lookupRes = 2.28 - rs.resolveMemberReference(tree, env, mref2, exprTree.type, tree.name, argtypes.toList(), null, true); 2.29 + rs.resolveMemberReference(tree, env, mref2, exprTree.type, 2.30 + tree.name, argtypes.toList(), null, true, rs.arityMethodCheck); 2.31 switch (lookupRes.fst.kind) { 2.32 //note: as argtypes are erroneous types, type-errors must 2.33 //have been caused by arity mismatch
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Apr 05 14:51:55 2013 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Mon Apr 08 15:51:41 2013 +0100 3.3 @@ -143,7 +143,6 @@ 3.4 boolean allowBoxing, 3.5 boolean useVarargs, 3.6 Resolve.MethodResolutionContext resolveContext, 3.7 - Resolve.MethodCheck methodCheck, 3.8 Warner warn) throws InferenceException { 3.9 //-System.err.println("instantiateMethod(" + tvars + ", " + mt + ", " + argtypes + ")"); //DEBUG 3.10 final InferenceContext inferenceContext = new InferenceContext(tvars); 3.11 @@ -152,7 +151,7 @@ 3.12 DeferredAttr.DeferredAttrContext deferredAttrContext = 3.13 resolveContext.deferredAttrContext(msym, inferenceContext, resultInfo, warn); 3.14 3.15 - methodCheck.argumentsAcceptable(env, deferredAttrContext, 3.16 + resolveContext.methodCheck.argumentsAcceptable(env, deferredAttrContext, 3.17 argtypes, mt.getParameterTypes(), warn); 3.18 3.19 if (allowGraphInference &&
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Apr 05 14:51:55 2013 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java Mon Apr 08 15:51:41 2013 +0100 4.3 @@ -508,7 +508,6 @@ 4.4 List<Type> typeargtypes, 4.5 boolean allowBoxing, 4.6 boolean useVarargs, 4.7 - MethodCheck methodCheck, 4.8 Warner warn) throws Infer.InferenceException { 4.9 4.10 Type mt = types.memberType(site, m); 4.11 @@ -561,10 +560,9 @@ 4.12 allowBoxing, 4.13 useVarargs, 4.14 currentResolutionContext, 4.15 - methodCheck, 4.16 warn); 4.17 4.18 - methodCheck.argumentsAcceptable(env, currentResolutionContext.deferredAttrContext(m, infer.emptyContext, resultInfo, warn), 4.19 + currentResolutionContext.methodCheck.argumentsAcceptable(env, currentResolutionContext.deferredAttrContext(m, infer.emptyContext, resultInfo, warn), 4.20 argtypes, mt.getParameterTypes(), warn); 4.21 return mt; 4.22 } 4.23 @@ -582,7 +580,7 @@ 4.24 currentResolutionContext.attrMode = DeferredAttr.AttrMode.CHECK; 4.25 MethodResolutionPhase step = currentResolutionContext.step = env.info.pendingResolutionPhase; 4.26 return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes, 4.27 - step.isBoxingRequired(), step.isVarargsRequired(), resolveMethodCheck, warn); 4.28 + step.isBoxingRequired(), step.isVarargsRequired(), warn); 4.29 } 4.30 finally { 4.31 currentResolutionContext = prevContext; 4.32 @@ -599,11 +597,10 @@ 4.33 List<Type> typeargtypes, 4.34 boolean allowBoxing, 4.35 boolean useVarargs, 4.36 - MethodCheck methodCheck, 4.37 Warner warn) { 4.38 try { 4.39 return rawInstantiate(env, site, m, resultInfo, argtypes, typeargtypes, 4.40 - allowBoxing, useVarargs, methodCheck, warn); 4.41 + allowBoxing, useVarargs, warn); 4.42 } catch (InapplicableMethodException ex) { 4.43 return null; 4.44 } 4.45 @@ -628,6 +625,12 @@ 4.46 List<Type> argtypes, 4.47 List<Type> formals, 4.48 Warner warn); 4.49 + 4.50 + /** 4.51 + * Retrieve the method check object that will be used during a 4.52 + * most specific check. 4.53 + */ 4.54 + MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict); 4.55 } 4.56 4.57 /** 4.58 @@ -661,6 +664,100 @@ 4.59 } 4.60 4.61 /** 4.62 + * Dummy method check object. All methods are deemed applicable, regardless 4.63 + * of their formal parameter types. 4.64 + */ 4.65 + MethodCheck nilMethodCheck = new MethodCheck() { 4.66 + public void argumentsAcceptable(Env<AttrContext> env, DeferredAttrContext deferredAttrContext, List<Type> argtypes, List<Type> formals, Warner warn) { 4.67 + //do nothing - method always applicable regardless of actuals 4.68 + } 4.69 + 4.70 + public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { 4.71 + return this; 4.72 + } 4.73 + }; 4.74 + 4.75 + /** 4.76 + * Base class for 'real' method checks. The class defines the logic for 4.77 + * iterating through formals and actuals and provides and entry point 4.78 + * that can be used by subclasses in order to define the actual check logic. 4.79 + */ 4.80 + abstract class AbstractMethodCheck implements MethodCheck { 4.81 + @Override 4.82 + public void argumentsAcceptable(final Env<AttrContext> env, 4.83 + DeferredAttrContext deferredAttrContext, 4.84 + List<Type> argtypes, 4.85 + List<Type> formals, 4.86 + Warner warn) { 4.87 + //should we expand formals? 4.88 + boolean useVarargs = deferredAttrContext.phase.isVarargsRequired(); 4.89 + 4.90 + //inference context used during this method check 4.91 + InferenceContext inferenceContext = deferredAttrContext.inferenceContext; 4.92 + 4.93 + Type varargsFormal = useVarargs ? formals.last() : null; 4.94 + 4.95 + if (varargsFormal == null && 4.96 + argtypes.size() != formals.size()) { 4.97 + reportMC(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args 4.98 + } 4.99 + 4.100 + while (argtypes.nonEmpty() && formals.head != varargsFormal) { 4.101 + checkArg(false, argtypes.head, formals.head, deferredAttrContext, warn); 4.102 + argtypes = argtypes.tail; 4.103 + formals = formals.tail; 4.104 + } 4.105 + 4.106 + if (formals.head != varargsFormal) { 4.107 + reportMC(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args 4.108 + } 4.109 + 4.110 + if (useVarargs) { 4.111 + //note: if applicability check is triggered by most specific test, 4.112 + //the last argument of a varargs is _not_ an array type (see JLS 15.12.2.5) 4.113 + final Type elt = types.elemtype(varargsFormal); 4.114 + while (argtypes.nonEmpty()) { 4.115 + checkArg(true, argtypes.head, elt, deferredAttrContext, warn); 4.116 + argtypes = argtypes.tail; 4.117 + } 4.118 + } 4.119 + } 4.120 + 4.121 + /** 4.122 + * Does the actual argument conforms to the corresponding formal? 4.123 + */ 4.124 + abstract void checkArg(boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn); 4.125 + 4.126 + protected void reportMC(MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) { 4.127 + boolean inferDiag = inferenceContext != infer.emptyContext; 4.128 + InapplicableMethodException ex = inferDiag ? 4.129 + infer.inferenceException : inapplicableMethodException; 4.130 + if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) { 4.131 + Object[] args2 = new Object[args.length + 1]; 4.132 + System.arraycopy(args, 0, args2, 1, args.length); 4.133 + args2[0] = inferenceContext.inferenceVars(); 4.134 + args = args2; 4.135 + } 4.136 + throw ex.setMessage(inferDiag ? diag.inferKey : diag.basicKey, args); 4.137 + } 4.138 + 4.139 + public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { 4.140 + return nilMethodCheck; 4.141 + } 4.142 + } 4.143 + 4.144 + /** 4.145 + * Arity-based method check. A method is applicable if the number of actuals 4.146 + * supplied conforms to the method signature. 4.147 + */ 4.148 + MethodCheck arityMethodCheck = new AbstractMethodCheck() { 4.149 + @Override 4.150 + void checkArg(boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) { 4.151 + //do nothing - actual always compatible to formals 4.152 + } 4.153 + }; 4.154 + 4.155 + /** 4.156 * Main method applicability routine. Given a list of actual types A, 4.157 * a list of formal types F, determines whether the types in A are 4.158 * compatible (by method invocation conversion) with the types in F. 4.159 @@ -678,62 +775,27 @@ 4.160 * 4.161 * A method check handler (see above) is used in order to report errors. 4.162 */ 4.163 - MethodCheck resolveMethodCheck = new MethodCheck() { 4.164 + MethodCheck resolveMethodCheck = new AbstractMethodCheck() { 4.165 + 4.166 + @Override 4.167 + void checkArg(boolean varargs, Type actual, Type formal, DeferredAttrContext deferredAttrContext, Warner warn) { 4.168 + ResultInfo mresult = methodCheckResult(varargs, formal, deferredAttrContext, warn); 4.169 + mresult.check(null, actual); 4.170 + } 4.171 + 4.172 @Override 4.173 public void argumentsAcceptable(final Env<AttrContext> env, 4.174 DeferredAttrContext deferredAttrContext, 4.175 List<Type> argtypes, 4.176 List<Type> formals, 4.177 Warner warn) { 4.178 + super.argumentsAcceptable(env, deferredAttrContext, argtypes, formals, warn); 4.179 //should we expand formals? 4.180 - boolean useVarargs = deferredAttrContext.phase.isVarargsRequired(); 4.181 - 4.182 - //inference context used during this method check 4.183 - InferenceContext inferenceContext = deferredAttrContext.inferenceContext; 4.184 - 4.185 - Type varargsFormal = useVarargs ? formals.last() : null; 4.186 - 4.187 - if (varargsFormal == null && 4.188 - argtypes.size() != formals.size()) { 4.189 - reportMC(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args 4.190 + if (deferredAttrContext.phase.isVarargsRequired()) { 4.191 + //check varargs element type accessibility 4.192 + varargsAccessible(env, types.elemtype(formals.last()), 4.193 + deferredAttrContext.inferenceContext); 4.194 } 4.195 - 4.196 - while (argtypes.nonEmpty() && formals.head != varargsFormal) { 4.197 - ResultInfo mresult = methodCheckResult(false, formals.head, deferredAttrContext, warn); 4.198 - mresult.check(null, argtypes.head); 4.199 - argtypes = argtypes.tail; 4.200 - formals = formals.tail; 4.201 - } 4.202 - 4.203 - if (formals.head != varargsFormal) { 4.204 - reportMC(MethodCheckDiag.ARITY_MISMATCH, inferenceContext); // not enough args 4.205 - } 4.206 - 4.207 - if (useVarargs) { 4.208 - //note: if applicability check is triggered by most specific test, 4.209 - //the last argument of a varargs is _not_ an array type (see JLS 15.12.2.5) 4.210 - final Type elt = types.elemtype(varargsFormal); 4.211 - ResultInfo mresult = methodCheckResult(true, elt, deferredAttrContext, warn); 4.212 - while (argtypes.nonEmpty()) { 4.213 - mresult.check(null, argtypes.head); 4.214 - argtypes = argtypes.tail; 4.215 - } 4.216 - //check varargs element type accessibility 4.217 - varargsAccessible(env, elt, inferenceContext); 4.218 - } 4.219 - } 4.220 - 4.221 - private void reportMC(MethodCheckDiag diag, InferenceContext inferenceContext, Object... args) { 4.222 - boolean inferDiag = inferenceContext != infer.emptyContext; 4.223 - InapplicableMethodException ex = inferDiag ? 4.224 - infer.inferenceException : inapplicableMethodException; 4.225 - if (inferDiag && (!diag.inferKey.equals(diag.basicKey))) { 4.226 - Object[] args2 = new Object[args.length + 1]; 4.227 - System.arraycopy(args, 0, args2, 1, args.length); 4.228 - args2[0] = inferenceContext.inferenceVars(); 4.229 - args = args2; 4.230 - } 4.231 - throw ex.setMessage(inferDiag ? diag.inferKey : diag.basicKey, args); 4.232 } 4.233 4.234 private void varargsAccessible(final Env<AttrContext> env, final Type t, final InferenceContext inferenceContext) { 4.235 @@ -765,6 +827,11 @@ 4.236 }; 4.237 return new MethodResultInfo(to, checkContext); 4.238 } 4.239 + 4.240 + @Override 4.241 + public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { 4.242 + return new MostSpecificCheck(strict, actuals); 4.243 + } 4.244 }; 4.245 4.246 /** 4.247 @@ -1042,6 +1109,11 @@ 4.248 } 4.249 } 4.250 } 4.251 + 4.252 + public MethodCheck mostSpecificCheck(List<Type> actuals, boolean strict) { 4.253 + Assert.error("Cannot get here!"); 4.254 + return null; 4.255 + } 4.256 } 4.257 4.258 public static class InapplicableMethodException extends RuntimeException { 4.259 @@ -1254,7 +1326,7 @@ 4.260 Assert.check(sym.kind < AMBIGUOUS); 4.261 try { 4.262 Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes, 4.263 - allowBoxing, useVarargs, resolveMethodCheck, types.noWarnings); 4.264 + allowBoxing, useVarargs, types.noWarnings); 4.265 if (!operator) 4.266 currentResolutionContext.addApplicableCandidate(sym, mt); 4.267 } catch (InapplicableMethodException ex) { 4.268 @@ -1358,11 +1430,20 @@ 4.269 int maxLength = Math.max( 4.270 Math.max(m1.type.getParameterTypes().length(), actuals.length()), 4.271 m2.type.getParameterTypes().length()); 4.272 - Type mst = instantiate(env, site, m2, null, 4.273 - adjustArgs(types.lowerBounds(types.memberType(site, m1).getParameterTypes()), m1, maxLength, useVarargs), null, 4.274 - allowBoxing, useVarargs, new MostSpecificCheck(!allowBoxing, actuals), noteWarner); 4.275 - return mst != null && 4.276 - !noteWarner.hasLint(Lint.LintCategory.UNCHECKED); 4.277 + MethodResolutionContext prevResolutionContext = currentResolutionContext; 4.278 + try { 4.279 + currentResolutionContext = new MethodResolutionContext(); 4.280 + currentResolutionContext.step = prevResolutionContext.step; 4.281 + currentResolutionContext.methodCheck = 4.282 + prevResolutionContext.methodCheck.mostSpecificCheck(actuals, !allowBoxing); 4.283 + Type mst = instantiate(env, site, m2, null, 4.284 + adjustArgs(types.lowerBounds(types.memberType(site, m1).getParameterTypes()), m1, maxLength, useVarargs), null, 4.285 + allowBoxing, useVarargs, noteWarner); 4.286 + return mst != null && 4.287 + !noteWarner.hasLint(Lint.LintCategory.UNCHECKED); 4.288 + } finally { 4.289 + currentResolutionContext = prevResolutionContext; 4.290 + } 4.291 } 4.292 private List<Type> adjustArgs(List<Type> args, Symbol msym, int length, boolean allowVarargs) { 4.293 if ((msym.flags() & VARARGS) != 0 && allowVarargs) { 4.294 @@ -2124,14 +2205,14 @@ 4.295 Name name, 4.296 List<Type> argtypes, 4.297 List<Type> typeargtypes) { 4.298 - return lookupMethod(env, pos, env.enclClass.sym, new BasicLookupHelper(name, env.enclClass.sym.type, argtypes, typeargtypes) { 4.299 - @Override 4.300 - Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) { 4.301 - return findFun(env, name, argtypes, typeargtypes, 4.302 - phase.isBoxingRequired(), 4.303 - phase.isVarargsRequired()); 4.304 - } 4.305 - }); 4.306 + return lookupMethod(env, pos, env.enclClass.sym, resolveMethodCheck, 4.307 + new BasicLookupHelper(name, env.enclClass.sym.type, argtypes, typeargtypes) { 4.308 + @Override 4.309 + Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) { 4.310 + return findFun(env, name, argtypes, typeargtypes, 4.311 + phase.isBoxingRequired(), 4.312 + phase.isVarargsRequired()); 4.313 + }}); 4.314 } 4.315 4.316 /** Resolve a qualified method identifier 4.317 @@ -2313,36 +2394,36 @@ 4.318 Type site, 4.319 List<Type> argtypes, 4.320 List<Type> typeargtypes) { 4.321 - return lookupMethod(env, pos, site.tsym, new BasicLookupHelper(names.init, site, argtypes, typeargtypes) { 4.322 - @Override 4.323 - Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) { 4.324 - return findDiamond(env, site, argtypes, typeargtypes, 4.325 - phase.isBoxingRequired(), 4.326 - phase.isVarargsRequired()); 4.327 - } 4.328 - @Override 4.329 - Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) { 4.330 - if (sym.kind >= AMBIGUOUS) { 4.331 - final JCDiagnostic details = sym.kind == WRONG_MTH ? 4.332 - ((InapplicableSymbolError)sym).errCandidate().details : 4.333 - null; 4.334 - sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) { 4.335 - @Override 4.336 - JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, 4.337 - Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) { 4.338 - String key = details == null ? 4.339 - "cant.apply.diamond" : 4.340 - "cant.apply.diamond.1"; 4.341 - return diags.create(dkind, log.currentSource(), pos, key, 4.342 - diags.fragment("diamond", site.tsym), details); 4.343 + return lookupMethod(env, pos, site.tsym, resolveMethodCheck, 4.344 + new BasicLookupHelper(names.init, site, argtypes, typeargtypes) { 4.345 + @Override 4.346 + Symbol lookup(Env<AttrContext> env, MethodResolutionPhase phase) { 4.347 + return findDiamond(env, site, argtypes, typeargtypes, 4.348 + phase.isBoxingRequired(), 4.349 + phase.isVarargsRequired()); 4.350 + } 4.351 + @Override 4.352 + Symbol access(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, Symbol sym) { 4.353 + if (sym.kind >= AMBIGUOUS) { 4.354 + final JCDiagnostic details = sym.kind == WRONG_MTH ? 4.355 + ((InapplicableSymbolError)sym).errCandidate().details : 4.356 + null; 4.357 + sym = new InapplicableSymbolError(sym.kind, "diamondError", currentResolutionContext) { 4.358 + @Override 4.359 + JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, 4.360 + Symbol location, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) { 4.361 + String key = details == null ? 4.362 + "cant.apply.diamond" : 4.363 + "cant.apply.diamond.1"; 4.364 + return diags.create(dkind, log.currentSource(), pos, key, 4.365 + diags.fragment("diamond", site.tsym), details); 4.366 + } 4.367 + }; 4.368 + sym = accessMethod(sym, pos, site, names.init, true, argtypes, typeargtypes); 4.369 + env.info.pendingResolutionPhase = currentResolutionContext.step; 4.370 } 4.371 - }; 4.372 - sym = accessMethod(sym, pos, site, names.init, true, argtypes, typeargtypes); 4.373 - env.info.pendingResolutionPhase = currentResolutionContext.step; 4.374 - } 4.375 - return sym; 4.376 - } 4.377 - }); 4.378 + return sym; 4.379 + }}); 4.380 } 4.381 4.382 /** This method scans all the constructor symbol in a given class scope - 4.383 @@ -2475,7 +2556,8 @@ 4.384 Type site, 4.385 Name name, List<Type> argtypes, 4.386 List<Type> typeargtypes, 4.387 - boolean boxingAllowed) { 4.388 + boolean boxingAllowed, 4.389 + MethodCheck methodCheck) { 4.390 MethodResolutionPhase maxPhase = boxingAllowed ? VARARITY : BASIC; 4.391 4.392 ReferenceLookupHelper boundLookupHelper; 4.393 @@ -2495,12 +2577,12 @@ 4.394 4.395 //step 1 - bound lookup 4.396 Env<AttrContext> boundEnv = env.dup(env.tree, env.info.dup()); 4.397 - Symbol boundSym = lookupMethod(boundEnv, env.tree.pos(), site.tsym, boundLookupHelper); 4.398 + Symbol boundSym = lookupMethod(boundEnv, env.tree.pos(), site.tsym, methodCheck, boundLookupHelper); 4.399 4.400 //step 2 - unbound lookup 4.401 ReferenceLookupHelper unboundLookupHelper = boundLookupHelper.unboundLookup(); 4.402 Env<AttrContext> unboundEnv = env.dup(env.tree, env.info.dup()); 4.403 - Symbol unboundSym = lookupMethod(unboundEnv, env.tree.pos(), site.tsym, unboundLookupHelper); 4.404 + Symbol unboundSym = lookupMethod(unboundEnv, env.tree.pos(), site.tsym, methodCheck, unboundLookupHelper); 4.405 4.406 //merge results 4.407 Pair<Symbol, ReferenceLookupHelper> res; 4.408 @@ -2671,7 +2753,7 @@ 4.409 ReferenceLookupHelper unboundLookup() { 4.410 if (TreeInfo.isStaticSelector(referenceTree.expr, names) && 4.411 argtypes.nonEmpty() && 4.412 - types.isSubtypeUnchecked(argtypes.head, site)) { 4.413 + (argtypes.head.hasTag(NONE) || types.isSubtypeUnchecked(argtypes.head, site))) { 4.414 return new UnboundMethodReferenceLookupHelper(referenceTree, name, 4.415 site, argtypes, typeargtypes, maxPhase); 4.416 } else { 4.417 @@ -2704,8 +2786,8 @@ 4.418 UnboundMethodReferenceLookupHelper(JCMemberReference referenceTree, Name name, Type site, 4.419 List<Type> argtypes, List<Type> typeargtypes, MethodResolutionPhase maxPhase) { 4.420 super(referenceTree, name, site, argtypes.tail, typeargtypes, maxPhase); 4.421 - Type asSuperSite = types.asSuper(argtypes.head, site.tsym); 4.422 - if (site.isRaw() && !asSuperSite.isErroneous()) { 4.423 + if (site.isRaw() && !argtypes.head.hasTag(NONE)) { 4.424 + Type asSuperSite = types.asSuper(argtypes.head, site.tsym); 4.425 this.site = asSuperSite; 4.426 } 4.427 } 4.428 @@ -2800,8 +2882,10 @@ 4.429 * at the end of the lookup, the helper is used to validate the results 4.430 * (this last step might trigger overload resolution diagnostics). 4.431 */ 4.432 - Symbol lookupMethod(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, LookupHelper lookupHelper) { 4.433 - return lookupMethod(env, pos, location, new MethodResolutionContext(), lookupHelper); 4.434 + Symbol lookupMethod(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, MethodCheck methodCheck, LookupHelper lookupHelper) { 4.435 + MethodResolutionContext resolveContext = new MethodResolutionContext(); 4.436 + resolveContext.methodCheck = methodCheck; 4.437 + return lookupMethod(env, pos, location, resolveContext, lookupHelper); 4.438 } 4.439 4.440 Symbol lookupMethod(Env<AttrContext> env, DiagnosticPosition pos, Symbol location, 4.441 @@ -3595,6 +3679,8 @@ 4.442 4.443 MethodResolutionPhase step = null; 4.444 4.445 + MethodCheck methodCheck = resolveMethodCheck; 4.446 + 4.447 private boolean internalResolution = false; 4.448 private DeferredAttr.AttrMode attrMode = DeferredAttr.AttrMode.SPECULATIVE; 4.449