Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-10-30 16:09:15 +0000
committerStephan Herrmann2018-10-30 16:09:15 +0000
commit6504b5e1cf9b5fc5fc315e8c943599e1d162a6f3 (patch)
treedd43df54d825691aa0e8331476581b41893999b4 /org.eclipse.jdt.core
parent6f260226ca5177db7f12a38288b2144423814f28 (diff)
downloadeclipse.jdt.core-6504b5e1cf9b5fc5fc315e8c943599e1d162a6f3.tar.gz
eclipse.jdt.core-6504b5e1cf9b5fc5fc315e8c943599e1d162a6f3.tar.xz
eclipse.jdt.core-6504b5e1cf9b5fc5fc315e8c943599e1d162a6f3.zip
Bug 540520 - Problem compiling annonymous inner classI20181030-1800
Diffstat (limited to 'org.eclipse.jdt.core')
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java7
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java5
2 files changed, 9 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java
index 4d6b5d56e9..349406911d 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java
@@ -1475,7 +1475,7 @@ public class LambdaExpression extends FunctionalExpression implements IPolyExpre
if (((LambdaExpression) lambdaScope2.referenceContext).sourceStart == LambdaExpression.this.sourceStart) {
// local type within this lambda needs replacement:
TypeBinding substType = this.localTypes2.get(orgLocal.sourceStart);
- if (substType != null) {
+ if (substType != null && substType != orgLocal) { //$IDENTITY-COMPARISON$
orgLocal.transferConstantPoolNameTo(substType);
return substType;
}
@@ -1501,10 +1501,11 @@ public class LambdaExpression extends FunctionalExpression implements IPolyExpre
/**
* Perform substitution with a {@link LocalTypeSubstitutor} on all types mentioned in the given method binding.
*/
- void updateLocalTypesInMethod(MethodBinding method) {
+ boolean updateLocalTypesInMethod(MethodBinding method) {
if (this.localTypes == null)
- return;
+ return false;
updateLocalTypesInMethod(method, new LocalTypeSubstitutor(this.localTypes), new NullSubstitution(this.scope.environment()));
+ return true;
}
private void updateLocalTypesInMethod(MethodBinding method, Substitutor substor, Substitution subst) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
index 78f4eea47c..d5b9f6fea0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ReturnStatement.java
@@ -358,6 +358,11 @@ public void resolve(BlockScope scope) {
if (methodType == null)
return;
+ if (methodType.isProperType(true) && lambda != null) {
+ // ensure that type conversions don't leak a preliminary local type:
+ if (lambda.updateLocalTypesInMethod(lambda.descriptor))
+ methodType = lambda.expectedResultType();
+ }
if (TypeBinding.notEquals(methodType, expressionType)) // must call before computeConversion() and typeMismatchError()
scope.compilationUnitScope().recordTypeConversion(methodType, expressionType);
if (this.expression.isConstantValueOfTypeAssignableToType(expressionType, methodType)

Back to the top