new compiler error message as to avoid generating illegal byte code before enhancement bug 310881 is implemented.
diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
index 6acf962..3a11f73 100644
--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/CompilerInvocationTests.java
@@ -1738,6 +1738,7 @@
expectedProblemAttributes.put("CalloutUndeclaredException", SKIP);
expectedProblemAttributes.put("CalloutOverrideReducesVisibility", SKIP);
expectedProblemAttributes.put("AddingInferredCalloutForInherited", SKIP);
+ expectedProblemAttributes.put("InferredCalloutInCompoundAssignment", SKIP);
expectedProblemAttributes.put("UsingInferredCalloutForMessageSend", SKIP);
expectedProblemAttributes.put("UnusedParamMap", SKIP);
expectedProblemAttributes.put("CalloutParameterMappingMissingSignatures", SKIP);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
index 1f5d390..471b5e4 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/core/compiler/IProblem.java
@@ -1530,6 +1530,7 @@
int AddingInferredCalloutForInherited = CALLOUT_RELATED + 1014; // 3.1(j)
int UsingInferredCalloutForMessageSend = CALLOUT_RELATED + 1015; // 3.1(j)
+ int InferredCalloutInCompoundAssignment = CALLOUT_RELATED + 1016; // 3.1(j)
int UnusedParamMap = CALLOUT_RELATED + 2001; // 3.2
int CalloutParameterMappingMissingSignatures = CALLOUT_RELATED + 2002; // 3.2(a)
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
index a3fac2f..0d9a6ce 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/ProblemReporter.java
@@ -9830,6 +9830,15 @@
send.sourceStart,
send.sourceEnd);
}
+public void inferredCalloutInCompoundAssignment(ASTNode location, char[] fieldName) {
+ String[] args = { String.valueOf(fieldName) };
+ this.handle(
+ IProblem.InferredCalloutInCompoundAssignment,
+ args,
+ args,
+ location.sourceStart,
+ location.sourceEnd);
+}
// -- 3.2 --
public void unusedParamMap(
AbstractMethodMappingDeclaration mappingDeclaration,
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
index 71b0c92..ec0887a 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/problem/messages.properties
@@ -804,6 +804,7 @@
#1301013
1301014 = Inherited abstract method {0} is implicitly bound as an inferred callout (OTJLD 3.1(j)).
1301015 = Unresolved self call {0} is implicitly bound by an inferred callout (OTJLD 3.1(j)).
+1301016 = Attempting to infer callout to base field {0} in a compound assignment (OTJLD 3.1(j)).
1302001 = Unused mapping for parameter {0} is ignored (OTJLD 3.2).
1302002 = Syntax error: parameter mapping allowed only if methods are specified with their signatures (OTJLD 3.2(a)).
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CalloutImplementor.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CalloutImplementor.java
index 551419a..f246ea6 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CalloutImplementor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CalloutImplementor.java
@@ -31,6 +31,7 @@
import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.core.compiler.IProblem;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.CastExpression;
@@ -1232,8 +1233,15 @@
AstGenerator gen= new AstGenerator(location.sourceStart, location.sourceEnd);
callout = inferCalloutToField(type, fieldName, accessorName, isSetter, expectedType, gen);
}
- if (callout != null)
+
+ if (callout != null) {
+ if ((location.bits & ASTNode.IsCompoundAssigned) != 0) {
+ // not legal in this context
+ scope.problemReporter().inferredCalloutInCompoundAssignment(location, fieldName);
+ return null;
+ }
scope.problemReporter().inferredUseOfCalloutToField(isSetter, location, fieldName, ((FieldAccessSpec)callout.baseMethodSpec).resolvedField);
+ }
return callout;
}