diff options
author | Stephan Herrmann | 2018-08-16 18:55:45 +0000 |
---|---|---|
committer | Stephan Herrmann | 2019-05-19 13:56:21 +0000 |
commit | c3bca83c3ba740ea3abc5cd2e334d9ab35a56b82 (patch) | |
tree | 244fe08313f6da2b0a30cb806507cec53227f62d /org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java | |
parent | 5147f38abb400d33a4aa49de5af5318835c60b88 (diff) | |
download | eclipse.jdt.core-c3bca83c3ba740ea3abc5cd2e334d9ab35a56b82.tar.gz eclipse.jdt.core-c3bca83c3ba740ea3abc5cd2e334d9ab35a56b82.tar.xz eclipse.jdt.core-c3bca83c3ba740ea3abc5cd2e334d9ab35a56b82.zip |
Bug 525822 - [1.8] ECJ compiles ambiguous lambda method invocation
without warning, breaking builds with javac.
Change-Id: Iaad08af8fe399311ed05252129037b7377f4fa72
Signed-off-by: Stephan Herrmann <stephan.herrmann@berlin.de>
Diffstat (limited to 'org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java')
-rw-r--r-- | org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java index 83bb061160..eb3f1abce1 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java @@ -48,6 +48,7 @@ *******************************************************************************/ package org.eclipse.jdt.internal.compiler.ast; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -677,11 +678,13 @@ public abstract class ASTNode implements TypeConstants, TypeIds { * @param method the method produced by lookup (possibly involving type inference). * @param argumentTypes the argument types as collected from first resolving the invocation arguments and as used for the method lookup. * @param scope scope for resolution. + * @return either the original method or a problem method */ - public static void resolvePolyExpressionArguments(Invocation invocation, MethodBinding method, TypeBinding[] argumentTypes, BlockScope scope) { + public static MethodBinding resolvePolyExpressionArguments(Invocation invocation, MethodBinding method, TypeBinding[] argumentTypes, BlockScope scope) { MethodBinding candidateMethod = method.isValidBinding() ? method : method instanceof ProblemMethodBinding ? ((ProblemMethodBinding) method).closestMatch : null; if (candidateMethod == null) - return; + return method; + ProblemMethodBinding problemMethod = null; boolean variableArity = candidateMethod.isVarargs(); final TypeBinding[] parameters = candidateMethod.parameters; Expression[] arguments = invocation.arguments(); @@ -704,8 +707,20 @@ public abstract class ASTNode implements TypeConstants, TypeIds { boolean skipKosherCheck = method.problemId() == ProblemReasons.Ambiguous; updatedArgumentType = lambda.resolveType(scope, skipKosherCheck); // additional checks, because LE.resolveType may return a valid binding even in the presence of structural errors - if (!lambda.isCompatibleWith(parameterType, scope) || lambda.hasErrors()) + if (lambda.hasErrors() || lambda.hasDescripterProblem) { + continue; + } + if (!lambda.isCompatibleWith(parameterType, scope)) { + if (method.isValidBinding() && problemMethod == null) { + TypeBinding[] originalArguments = Arrays.copyOf(argumentTypes, argumentTypes.length); + if (lambda.reportShapeError(parameterType, scope)) { + problemMethod = new ProblemMethodBinding(candidateMethod, method.selector, originalArguments, ProblemReasons.ErrorAlreadyReported); + } else { + problemMethod = new ProblemMethodBinding(candidateMethod, method.selector, originalArguments, ProblemReasons.NotFound); + } + } continue; + } // avoid that preliminary local type bindings escape beyond this point: lambda.updateLocalTypesInMethod(candidateMethod); } else { @@ -723,6 +738,9 @@ public abstract class ASTNode implements TypeConstants, TypeIds { if (ic18 != null) ic18.flushBoundOutbox(); // overload resolution is done, now perform the push of bounds from inner to outer } + if (problemMethod != null) + return problemMethod; + return method; } public static void resolveAnnotations(BlockScope scope, Annotation[] sourceAnnotations, Binding recipient) { |