1407 env.info.varArgs = errPhase.isVarargsRequired(); |
1409 env.info.varArgs = errPhase.isVarargsRequired(); |
1408 } |
1410 } |
1409 return sym; |
1411 return sym; |
1410 } |
1412 } |
1411 |
1413 |
|
1414 /** Resolve constructor using diamond inference. |
|
1415 * @param pos The position to use for error reporting. |
|
1416 * @param env The environment current at the constructor invocation. |
|
1417 * @param site The type of class for which a constructor is searched. |
|
1418 * The scope of this class has been touched in attribution. |
|
1419 * @param argtypes The types of the constructor invocation's value |
|
1420 * arguments. |
|
1421 * @param typeargtypes The types of the constructor invocation's type |
|
1422 * arguments. |
|
1423 */ |
|
1424 Symbol resolveDiamond(DiagnosticPosition pos, |
|
1425 Env<AttrContext> env, |
|
1426 Type site, |
|
1427 List<Type> argtypes, |
|
1428 List<Type> typeargtypes, boolean reportErrors) { |
|
1429 Symbol sym = methodNotFound; |
|
1430 JCDiagnostic explanation = null; |
|
1431 List<MethodResolutionPhase> steps = methodResolutionSteps; |
|
1432 while (steps.nonEmpty() && |
|
1433 steps.head.isApplicable(boxingEnabled, varargsEnabled) && |
|
1434 sym.kind >= ERRONEOUS) { |
|
1435 sym = resolveConstructor(pos, env, site, argtypes, typeargtypes, |
|
1436 steps.head.isBoxingRequired(), |
|
1437 env.info.varArgs = steps.head.isVarargsRequired()); |
|
1438 methodResolutionCache.put(steps.head, sym); |
|
1439 if (sym.kind == WRONG_MTH && |
|
1440 ((InapplicableSymbolError)sym).explanation != null) { |
|
1441 //if the symbol is an inapplicable method symbol, then the |
|
1442 //explanation contains the reason for which inference failed |
|
1443 explanation = ((InapplicableSymbolError)sym).explanation; |
|
1444 } |
|
1445 steps = steps.tail; |
|
1446 } |
|
1447 if (sym.kind >= AMBIGUOUS && reportErrors) { |
|
1448 String key = explanation == null ? |
|
1449 "cant.apply.diamond" : |
|
1450 "cant.apply.diamond.1"; |
|
1451 log.error(pos, key, diags.fragment("diamond", site.tsym), explanation); |
|
1452 } |
|
1453 return sym; |
|
1454 } |
|
1455 |
1412 /** Resolve constructor. |
1456 /** Resolve constructor. |
1413 * @param pos The position to use for error reporting. |
1457 * @param pos The position to use for error reporting. |
1414 * @param env The environment current at the constructor invocation. |
1458 * @param env The environment current at the constructor invocation. |
1415 * @param site The type of class for which a constructor is searched. |
1459 * @param site The type of class for which a constructor is searched. |
1416 * @param argtypes The types of the constructor invocation's value |
1460 * @param argtypes The types of the constructor invocation's value |