38 import com.sun.tools.javac.tree.JCTree.*; |
38 import com.sun.tools.javac.tree.JCTree.*; |
39 |
39 |
40 import static com.sun.tools.javac.code.Flags.*; |
40 import static com.sun.tools.javac.code.Flags.*; |
41 import static com.sun.tools.javac.code.Kinds.*; |
41 import static com.sun.tools.javac.code.Kinds.*; |
42 import static com.sun.tools.javac.code.TypeTags.*; |
42 import static com.sun.tools.javac.code.TypeTags.*; |
|
43 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType; |
43 import javax.lang.model.element.ElementVisitor; |
44 import javax.lang.model.element.ElementVisitor; |
44 |
45 |
45 import java.util.Map; |
46 import java.util.Map; |
46 import java.util.HashMap; |
47 import java.util.HashMap; |
47 |
48 |
1445 */ |
1446 */ |
1446 Symbol resolveDiamond(DiagnosticPosition pos, |
1447 Symbol resolveDiamond(DiagnosticPosition pos, |
1447 Env<AttrContext> env, |
1448 Env<AttrContext> env, |
1448 Type site, |
1449 Type site, |
1449 List<Type> argtypes, |
1450 List<Type> argtypes, |
1450 List<Type> typeargtypes, boolean reportErrors) { |
1451 List<Type> typeargtypes) { |
1451 Symbol sym = methodNotFound; |
1452 Symbol sym = methodNotFound; |
1452 JCDiagnostic explanation = null; |
1453 JCDiagnostic explanation = null; |
1453 List<MethodResolutionPhase> steps = methodResolutionSteps; |
1454 List<MethodResolutionPhase> steps = methodResolutionSteps; |
1454 while (steps.nonEmpty() && |
1455 while (steps.nonEmpty() && |
1455 steps.head.isApplicable(boxingEnabled, varargsEnabled) && |
1456 steps.head.isApplicable(boxingEnabled, varargsEnabled) && |
1464 //explanation contains the reason for which inference failed |
1465 //explanation contains the reason for which inference failed |
1465 explanation = ((InapplicableSymbolError)sym).explanation; |
1466 explanation = ((InapplicableSymbolError)sym).explanation; |
1466 } |
1467 } |
1467 steps = steps.tail; |
1468 steps = steps.tail; |
1468 } |
1469 } |
1469 if (sym.kind >= AMBIGUOUS && reportErrors) { |
1470 if (sym.kind >= AMBIGUOUS) { |
1470 String key = explanation == null ? |
1471 final JCDiagnostic details = explanation; |
1471 "cant.apply.diamond" : |
1472 Symbol errSym = new ResolveError(WRONG_MTH, "diamond error") { |
1472 "cant.apply.diamond.1"; |
1473 @Override |
1473 log.error(pos, key, diags.fragment("diamond", site.tsym), explanation); |
1474 JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Type site, Name name, List<Type> argtypes, List<Type> typeargtypes) { |
|
1475 String key = details == null ? |
|
1476 "cant.apply.diamond" : |
|
1477 "cant.apply.diamond.1"; |
|
1478 return diags.create(dkind, log.currentSource(), pos, key, diags.fragment("diamond", site.tsym), details); |
|
1479 } |
|
1480 }; |
|
1481 MethodResolutionPhase errPhase = firstErroneousResolutionPhase(); |
|
1482 sym = access(errSym, pos, site, names.init, true, argtypes, typeargtypes); |
|
1483 env.info.varArgs = errPhase.isVarargsRequired(); |
1474 } |
1484 } |
1475 return sym; |
1485 return sym; |
1476 } |
1486 } |
1477 |
1487 |
1478 /** Resolve constructor. |
1488 /** Resolve constructor. |