src/share/classes/com/sun/tools/javac/comp/Resolve.java

changeset 537
9d9d08922405
parent 325
ad07b7ea9685
child 547
04cf82179fa7
child 571
f0e3ec1f9d9f
equal deleted inserted replaced
536:396b117c1743 537:9d9d08922405
786 allowBoxing, 786 allowBoxing,
787 useVarargs, 787 useVarargs,
788 operator); 788 operator);
789 } 789 }
790 } 790 }
791 if (name == names.init)
792 break;
791 //- System.out.println(" - " + bestSoFar); 793 //- System.out.println(" - " + bestSoFar);
792 if (abstractok) { 794 if (abstractok) {
793 Symbol concrete = methodNotFound; 795 Symbol concrete = methodNotFound;
794 if ((bestSoFar.flags() & ABSTRACT) == 0) 796 if ((bestSoFar.flags() & ABSTRACT) == 0)
795 concrete = bestSoFar; 797 concrete = bestSoFar;
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

mercurial