Skip to content

Commit a6af724

Browse files
Almost complete revert of Bug 452788 (#4624)
commit being reverted: bac0b68 see #4624
1 parent 835cf96 commit a6af724

File tree

13 files changed

+21
-74
lines changed

13 files changed

+21
-74
lines changed

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public class AllocationExpression extends Expression implements IPolyExpression,
9191
// hold on to this context from invocation applicability inference until invocation type inference (per method candidate):
9292
private Map<ParameterizedGenericMethodBinding, InferenceContext18> inferenceContexts;
9393
public HashMap<TypeBinding, MethodBinding> solutionsPerTargetType;
94-
private InferenceContext18 outerInferenceContext; // resolving within the context of an outer (lambda) inference?
9594
public boolean argsContainCast;
9695
public TypeBinding[] argumentTypes = Binding.NO_PARAMETERS;
9796
public boolean argumentsHaveErrors = false;
@@ -855,7 +854,6 @@ public void cleanUpInferenceContexts() {
855854
value.cleanUp();
856855
}
857856
this.inferenceContexts = null;
858-
this.outerInferenceContext = null;
859857
this.solutionsPerTargetType = null;
860858
}
861859

@@ -866,7 +864,7 @@ public ExpressionContext getExpressionContext() {
866864
}
867865
@Override
868866
public InferenceContext18 freshInferenceContext(Scope scope) {
869-
return new InferenceContext18(scope, this.arguments, this, this.outerInferenceContext);
867+
return new InferenceContext18(scope, this.arguments, this);
870868
}
871869
@Override
872870
public int nameSourceStart() {

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ public Expression[] arguments() {
607607
// -- interface InvocationSite: --
608608
@Override
609609
public InferenceContext18 freshInferenceContext(Scope scope) {
610-
return new InferenceContext18(scope, this.arguments, this, null);
610+
return new InferenceContext18(scope, this.arguments, this);
611611
}
612612
@Override
613613
public int nameSourceEnd() {

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/Expression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ public TypeBinding resolveTypeExpecting(BlockScope scope, TypeBinding expectedTy
11151115
return expressionType;
11161116
}
11171117

1118-
public Expression resolveExpressionExpecting(TypeBinding targetType, Scope scope, InferenceContext18 context) {
1118+
public Expression resolveExpressionExpecting(TypeBinding targetType, Scope scope) {
11191119
return this; // subclasses should implement for a better resolved expression if required.
11201120
}
11211121

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/IPolyExpression.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.eclipse.jdt.internal.compiler.ast;
1717

1818
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
19-
import org.eclipse.jdt.internal.compiler.lookup.InferenceContext18;
2019
import org.eclipse.jdt.internal.compiler.lookup.InvocationSite;
2120
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
2221
import org.eclipse.jdt.internal.compiler.lookup.PolyTypeBinding;
@@ -64,6 +63,6 @@ public interface IPolyExpression {
6463
*/
6564
public TypeBinding resolveType(BlockScope blockScope);
6665
// Resolve expression tentatively - should have no lingering side-effects that may impact final resolution !
67-
public Expression resolveExpressionExpecting(TypeBinding targetType, Scope scope, InferenceContext18 inferenceContext);
66+
public Expression resolveExpressionExpecting(TypeBinding targetType, Scope scope);
6867

6968
}

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/LambdaExpression.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ public class LambdaExpression extends FunctionalExpression implements IPolyExpre
102102
private static final Block NO_BODY = new Block(0);
103103
private HashMap<TypeBinding, LambdaExpression> copiesPerTargetType;
104104
protected Expression [] resultExpressions = NO_EXPRESSIONS;
105-
public InferenceContext18 inferenceContext; // when performing tentative resolve keep a back reference to the driving context
106105
private Map<Integer/*sourceStart*/, LocalTypeBinding> localTypes; // support look-up of a local type from this lambda copy
107106
public boolean hasVarTypedArguments = false;
108107
int firstLocalLocal; // analysis index of first local variable (if any) post parameter(s) in the lambda; ("local local" as opposed to "outer local")
@@ -882,7 +881,7 @@ CompatibilityResult internalIsCompatibleWith(TypeBinding targetType, Scope skope
882881

883882
LambdaExpression copy = null;
884883
try {
885-
copy = cachedResolvedCopy(targetType, argumentsTypeElided(), false, null, skope); // if argument types are elided, we don't care for result expressions against *this* target, any valid target is OK.
884+
copy = cachedResolvedCopy(targetType, argumentsTypeElided(), false, skope); // if argument types are elided, we don't care for result expressions against *this* target, any valid target is OK.
886885
} catch (CopyFailureException cfe) {
887886
if (this.assistNode)
888887
return CompatibilityResult.COMPATIBLE; // can't type check result expressions, just say yes.
@@ -936,7 +935,7 @@ static class CopyFailureException extends RuntimeException {
936935
private static final long serialVersionUID = 1L;
937936
}
938937

939-
private LambdaExpression cachedResolvedCopy(TypeBinding targetType, boolean anyTargetOk, boolean requireExceptionAnalysis, InferenceContext18 context, Scope outerScope) {
938+
private LambdaExpression cachedResolvedCopy(TypeBinding targetType, boolean anyTargetOk, boolean requireExceptionAnalysis, Scope outerScope) {
940939
if (this.committed && outerScope instanceof BlockScope) {
941940
this.enclosingScope = (BlockScope) outerScope;
942941
// trust the result of any previous shape analysis:
@@ -981,7 +980,6 @@ private LambdaExpression cachedResolvedCopy(TypeBinding targetType, boolean anyT
981980

982981
copy.setExpressionContext(this.expressionContext);
983982
copy.setExpectedType(targetType);
984-
copy.inferenceContext = context;
985983
TypeBinding type = copy.resolveType(this.enclosingScope, true);
986984
if (type == null || !type.isValidBinding())
987985
return null;
@@ -1009,10 +1007,10 @@ private LambdaExpression cachedResolvedCopy(TypeBinding targetType, boolean anyT
10091007
* @return a resolved copy of 'this' or null if significant errors where encountered
10101008
*/
10111009
@Override
1012-
public LambdaExpression resolveExpressionExpecting(TypeBinding targetType, Scope skope, InferenceContext18 context) {
1010+
public LambdaExpression resolveExpressionExpecting(TypeBinding targetType, Scope skope) {
10131011
LambdaExpression copy = null;
10141012
try {
1015-
copy = cachedResolvedCopy(targetType, false, true, context, null /* to be safe we signal: not yet committed */);
1013+
copy = cachedResolvedCopy(targetType, false, true, null /* to be safe we signal: not yet committed */);
10161014
} catch (CopyFailureException cfe) {
10171015
return null;
10181016
}
@@ -1065,7 +1063,7 @@ public boolean sIsMoreSpecific(TypeBinding s, TypeBinding t, Scope skope) {
10651063

10661064
LambdaExpression copy;
10671065
try {
1068-
copy = cachedResolvedCopy(s, true /* any resolved copy is good */, false, null, null /*not yet committed*/); // we expect a cached copy - otherwise control won't reach here.
1066+
copy = cachedResolvedCopy(s, true /* any resolved copy is good */, false, null /*not yet committed*/); // we expect a cached copy - otherwise control won't reach here.
10691067
} catch (CopyFailureException cfe) {
10701068
if (this.assistNode)
10711069
return false;

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/MessageSend.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ public class MessageSend extends Expression implements IPolyExpression, Invocati
108108
// hold on to this context from invocation applicability inference until invocation type inference (per method candidate):
109109
private Map<ParameterizedGenericMethodBinding, InferenceContext18> inferenceContexts;
110110
private HashMap<TypeBinding, MethodBinding> solutionsPerTargetType;
111-
private InferenceContext18 outerInferenceContext; // resolving within the context of an outer (lambda) inference?
112111

113112
private boolean receiverIsType;
114113
protected boolean argsContainCast;
@@ -1117,11 +1116,6 @@ protected TypeBinding handleNullnessCodePatterns(BlockScope scope, TypeBinding r
11171116
}
11181117

11191118
protected TypeBinding findMethodBinding(BlockScope scope) {
1120-
ReferenceContext referenceContext = scope.methodScope().referenceContext;
1121-
if (referenceContext instanceof LambdaExpression) {
1122-
this.outerInferenceContext = ((LambdaExpression) referenceContext).inferenceContext;
1123-
}
1124-
11251119
if (this.expectedType != null && this.binding instanceof PolyParameterizedGenericMethodBinding) {
11261120
this.binding = this.solutionsPerTargetType.get(this.expectedType);
11271121
}
@@ -1338,7 +1332,6 @@ public void cleanUpInferenceContexts() {
13381332
value.cleanUp();
13391333
}
13401334
this.inferenceContexts = null;
1341-
this.outerInferenceContext = null;
13421335
this.solutionsPerTargetType = null;
13431336
}
13441337
@Override
@@ -1352,7 +1345,7 @@ public ExpressionContext getExpressionContext() {
13521345
// -- Interface InvocationSite: --
13531346
@Override
13541347
public InferenceContext18 freshInferenceContext(Scope scope) {
1355-
return new InferenceContext18(scope, this.arguments, this, this.outerInferenceContext);
1348+
return new InferenceContext18(scope, this.arguments, this);
13561349
}
13571350
@Override
13581351
public boolean isQualifiedSuper() {

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/ast/ReferenceExpression.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ public InferenceContext18 getInferenceContext(ParameterizedMethodBinding method)
10281028
}
10291029

10301030
@Override
1031-
public ReferenceExpression resolveExpressionExpecting(TypeBinding targetType, Scope scope, InferenceContext18 inferenceContext) {
1031+
public ReferenceExpression resolveExpressionExpecting(TypeBinding targetType, Scope scope) {
10321032
if (this.exactMethodBinding != null) { // We may see inference variables in target type.
10331033
MethodBinding functionType = targetType.getSingleAbstractMethod(scope, true);
10341034
if (functionType == null || functionType.problemId() == ProblemReasons.NoSuchSingleAbstractMethod)
@@ -1080,7 +1080,7 @@ public TypeBinding[] genericTypeArguments() {
10801080
public InferenceContext18 freshInferenceContext(Scope scope) {
10811081
if (this.expressionContext != ExpressionContext.VANILLA_CONTEXT) {
10821082
Expression[] arguments = createPseudoExpressions(this.freeParameters);
1083-
return new InferenceContext18(scope, arguments, this, null);
1083+
return new InferenceContext18(scope, arguments, this);
10841084
}
10851085
return null; // shouldn't happen, actually
10861086
}

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/BoundSet.java

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,25 +1302,6 @@ private void allSuperPairsWithCommonGenericTypeRecursive(TypeBinding s, TypeBind
13021302
}
13031303
}
13041304

1305-
public TypeBinding getEquivalentOuterVariable(InferenceVariable variable, InferenceVariable[] outerVariables) {
1306-
ThreeSets three = this.boundsPerVariable.get(variable);
1307-
if (three != null) {
1308-
for (TypeBound bound : three.sameBounds) {
1309-
for (InferenceVariable iv : outerVariables)
1310-
if (TypeBinding.equalsEquals(bound.right, iv))
1311-
return iv;
1312-
}
1313-
}
1314-
for (InferenceVariable iv : outerVariables) {
1315-
three = this.boundsPerVariable.get(iv);
1316-
if (three != null && three.sameBounds != null) {
1317-
for (TypeBound bound : three.sameBounds)
1318-
if (TypeBinding.equalsEquals(bound.right, variable))
1319-
return iv;
1320-
}
1321-
}
1322-
return null;
1323-
}
13241305
public TypeBinding condition18_5_5_item_4(
13251306
ReferenceBinding rAlpha,
13261307
InferenceVariable[] alpha,

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintExceptionFormula.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ public Object reduce(InferenceContext18 inferenceContext) {
8888

8989
TypeBinding[] ePrime = null;
9090
if (this.left instanceof LambdaExpression) {
91-
LambdaExpression lambda = ((LambdaExpression) this.left).resolveExpressionExpecting(this.right, inferenceContext.scope, inferenceContext);
91+
LambdaExpression lambda = ((LambdaExpression) this.left).resolveExpressionExpecting(this.right, inferenceContext.scope);
9292
if (lambda == null)
9393
return TRUE; // cannot make use of this buggy constraint
9494
ePrime = lambda.getThrownExceptions().toArray(TypeBinding[]::new);
9595
} else {
96-
ReferenceExpression referenceExpression = ((ReferenceExpression) this.left).resolveExpressionExpecting(this.right, scope, inferenceContext);
96+
ReferenceExpression referenceExpression = ((ReferenceExpression) this.left).resolveExpressionExpecting(this.right, scope);
9797
MethodBinding method = referenceExpression != null ? referenceExpression.binding : null;
9898
if (method != null)
9999
ePrime = method.thrownExceptions;

org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/lookup/ConstraintExpressionFormula.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public Object reduce(InferenceContext18 inferenceContext) throws InferenceFailur
185185
for (TypeBinding parameter : parameters)
186186
if (!parameter.isProperType(true))
187187
return FALSE;
188-
lambda = lambda.resolveExpressionExpecting(t, inferenceContext.scope, inferenceContext);
188+
lambda = lambda.resolveExpressionExpecting(t, inferenceContext.scope);
189189
if (lambda == null)
190190
return FALSE; // not strictly unreduceable, but proceeding with TRUE would likely produce secondary errors
191191
if (functionType.returnType == TypeBinding.VOID) {
@@ -268,7 +268,7 @@ private Object reduceReferenceExpressionCompatibility(ReferenceExpression refere
268268
if (functionType == null)
269269
return FALSE;
270270
// potentially-applicable method for the method reference when targeting T (15.13.1),
271-
reference = reference.resolveExpressionExpecting(t, inferenceContext.scope, inferenceContext);
271+
reference = reference.resolveExpressionExpecting(t, inferenceContext.scope);
272272
MethodBinding potentiallyApplicable = reference != null ? reference.binding : null;
273273
if (potentiallyApplicable == null)
274274
return FALSE;
@@ -518,7 +518,7 @@ Collection<InferenceVariable> inputVariables(final InferenceContext18 context) {
518518
if (sam.returnType != TypeBinding.VOID) {
519519
// ii)
520520
final TypeBinding r = sam.returnType;
521-
LambdaExpression resolved = lambda.resolveExpressionExpecting(this.right, context.scope, context);
521+
LambdaExpression resolved = lambda.resolveExpressionExpecting(this.right, context.scope);
522522
Expression[] resultExpressions = resolved != null ? resolved.resultExpressions() : null;
523523
for (int i = 0, length = resultExpressions == null ? 0 : resultExpressions.length; i < length; i++) {
524524
variables.addAll(new ConstraintExpressionFormula(resultExpressions[i], r, COMPATIBLE).inputVariables(context));

0 commit comments

Comments
 (0)