Bug 545316 - Parser throws CCE on ParameterMappingDeclaration
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index 6788221..00b9f3e 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -2483,14 +2483,17 @@
// find callin decl produced by CallinBindingLeftLong:
int paramlength = 0;
- if (this.currentElement == null)
+ if (this.currentElement == null) {
+ if (!this.diet)
+ concatNodeLists();
paramlength = this.astLengthStack[this.astLengthPtr--]; // no param mappings in recovery mode.
+ }
int callinPtr = this.astPtr - paramlength;
CallinMappingDeclaration callinBinding = (CallinMappingDeclaration) this.astStack[callinPtr];
// CallinParameterMappingsopt
boolean pendingParamMappings= this.intStack[this.intPtr--] == 1; // pushed in consumeNestedParamMappings/consumeParameterMappingsEmpty
- if (pendingParamMappings)
+ if (pendingParamMappings && this.diet)
callinBinding.mappings= AbstractMethodMappingDeclaration.PENDING_MAPPINGS;
else
copyParamMappingsAndPositions(paramlength, callinBinding);
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/model/org/eclipse/objectteams/otdt/tests/otmodel/OTReconcilerTests.java b/testplugins/org.eclipse.objectteams.otdt.tests/model/org/eclipse/objectteams/otdt/tests/otmodel/OTReconcilerTests.java
index e95d3e2..d4c7a3a 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/model/org/eclipse/objectteams/otdt/tests/otmodel/OTReconcilerTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/model/org/eclipse/objectteams/otdt/tests/otmodel/OTReconcilerTests.java
@@ -2218,6 +2218,163 @@
}
}
+ public void testBug545316a() throws CoreException, InterruptedException {
+ try {
+ // Resources creation
+ IJavaProject p = createOTJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin");
+ IProject project = p.getProject();
+ IProjectDescription prjDesc = project.getDescription();
+ //prjDesc.setNatureIds(OTDTPlugin.createProjectNatures(prjDesc));
+ prjDesc.setBuildSpec(OTDTPlugin.createProjectBuildCommands(prjDesc));
+ project.setDescription(prjDesc, null);
+
+ OTREContainer.initializeOTJProject(project);
+
+ createFolder("/P/src/pbase");
+ createFile(
+ "/P/src/pbase/Base.java",
+ "package pbase;\n" +
+ "public class Base {\n" +
+ " public void baseMethod(int flag, String name) {}\n" +
+ "}\n"
+ );
+
+ String sourceFoo =
+ "import base pbase.Base;\n" +
+ "public team class Foo {\n" +
+ " @SuppressWarnings(\"unused\") private String v1;\n" +
+ " @SuppressWarnings(\"unused\") private String v2;\n" +
+ " @SuppressWarnings(\"unused\") private String v3;\n" +
+ " @SuppressWarnings(\"unused\") private String v4;\n" +
+ " @SuppressWarnings(\"unused\") private String v5;\n" +
+ " @SuppressWarnings(\"unused\") private String v6;\n" +
+ " @SuppressWarnings(\"unused\") private String v7;\n" +
+ " @SuppressWarnings(\"unused\") private String v8;\n" +
+ " @SuppressWarnings(\"unused\") private String v9;\n" +
+ " @SuppressWarnings(\"unused\") private String v10;\n" +
+ " @SuppressWarnings(\"unused\") private String v11;\n" +
+ " protected class R playedBy Base {\n" +
+ " void roleMethod(String onlyThis) {}\n" +
+ " void roleMethod(String onlyThis) <- after void baseMethod(int flag, String name)\n" +
+ " with { onlyThis <- name }\n" +
+ " }\n" +
+ "}\n";
+ this.createFile(
+ "/P/src/Foo.java",
+ sourceFoo
+ );
+
+ char[] sourceChars = sourceFoo.toCharArray();
+ this.problemRequestor.initialize(sourceChars);
+
+ ICompilationUnit fooWC = getCompilationUnit("/P/src/Foo.java").getWorkingCopy(this.wcOwner, null);
+ IType foo = fooWC.getType("Foo");
+
+ CompilerOptions compilerOptions = new CompilerOptions(p.getOptions(true));
+ ProblemReporter problemReporter = new ProblemReporter(
+ DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+ compilerOptions,
+ new DefaultProblemFactory());
+
+ // force usage of type converter:
+ CompilationUnitDeclaration parsedUnit =
+ SourceTypeConverter.buildCompilationUnit(
+ new ISourceType[] {(ISourceType) ((SourceType)foo).getElementInfo()},
+ SourceTypeConverter.FIELD_AND_METHOD | SourceTypeConverter.MEMBER_TYPE | SourceTypeConverter.LOCAL_TYPE,
+ problemReporter,
+ new CompilationResult("Foo.java".toCharArray(), 1, 1, 90));
+
+ // force resolving:
+ process(parsedUnit, p, compilerOptions, problemReporter, ITranslationStates.STATE_RESOLVED);
+
+ // evaluate result:
+ CategorizedProblem[] problems = parsedUnit.compilationResult().problems;
+ assertNull(problems);
+ } finally {
+ deleteProject("P");
+ }
+ }
+
+ public void testBug545316b() throws CoreException, InterruptedException {
+ try {
+ // Resources creation
+ IJavaProject p = createOTJavaProject("P", new String[] {"src"}, new String[] {"JCL15_LIB"}, "bin");
+ IProject project = p.getProject();
+ IProjectDescription prjDesc = project.getDescription();
+ //prjDesc.setNatureIds(OTDTPlugin.createProjectNatures(prjDesc));
+ prjDesc.setBuildSpec(OTDTPlugin.createProjectBuildCommands(prjDesc));
+ project.setDescription(prjDesc, null);
+
+ OTREContainer.initializeOTJProject(project);
+
+ createFolder("/P/src/pbase");
+ createFile(
+ "/P/src/pbase/Base.java",
+ "package pbase;\n" +
+ "public class Base {\n" +
+ " public void baseMethod(int flag, String name) {}\n" +
+ "}\n"
+ );
+
+ String sourceFoo =
+ "import base pbase.Base;\n" +
+ "public team class Foo {\n" +
+ " @SuppressWarnings(\"unused\") private String v1;\n" +
+ " @SuppressWarnings(\"unused\") private String v2;\n" +
+ " @SuppressWarnings(\"unused\") private String v3;\n" +
+ " @SuppressWarnings(\"unused\") private String v4;\n" +
+ " @SuppressWarnings(\"unused\") private String v5;\n" +
+ " @SuppressWarnings(\"unused\") private String v6;\n" +
+ " @SuppressWarnings(\"unused\") private String v7;\n" +
+ " @SuppressWarnings(\"unused\") private String v8;\n" +
+ " @SuppressWarnings(\"unused\") private String v9;\n" +
+ " @SuppressWarnings(\"unused\") private String v10;\n" +
+ " @SuppressWarnings(\"unused\") private String v11;\n" +
+ " protected class R playedBy Base {\n" +
+ " void roleMethod(int f, String both) {}\n" +
+ " void m2(String onlyThis) {}\n" +
+ " void m2(String onlyThis) <- before void baseMethod(int flag, String name)\n" +
+ " with { onlyThis <- name }\n" +
+ " void roleMethod(int f, String both) <- after void baseMethod(int flag, String name)\n" +
+ " with { f <- flag, both <- name }\n" +
+ " }\n" +
+ "}\n";
+ this.createFile(
+ "/P/src/Foo.java",
+ sourceFoo
+ );
+
+ char[] sourceChars = sourceFoo.toCharArray();
+ this.problemRequestor.initialize(sourceChars);
+
+ ICompilationUnit fooWC = getCompilationUnit("/P/src/Foo.java").getWorkingCopy(this.wcOwner, null);
+ IType foo = fooWC.getType("Foo");
+
+ CompilerOptions compilerOptions = new CompilerOptions(p.getOptions(true));
+ ProblemReporter problemReporter = new ProblemReporter(
+ DefaultErrorHandlingPolicies.proceedWithAllProblems(),
+ compilerOptions,
+ new DefaultProblemFactory());
+
+ // force usage of type converter:
+ CompilationUnitDeclaration parsedUnit =
+ SourceTypeConverter.buildCompilationUnit(
+ new ISourceType[] {(ISourceType) ((SourceType)foo).getElementInfo()},
+ SourceTypeConverter.FIELD_AND_METHOD | SourceTypeConverter.MEMBER_TYPE | SourceTypeConverter.LOCAL_TYPE,
+ problemReporter,
+ new CompilationResult("Foo.java".toCharArray(), 1, 1, 90));
+
+ // force resolving:
+ process(parsedUnit, p, compilerOptions, problemReporter, ITranslationStates.STATE_RESOLVED);
+
+ // evaluate result:
+ CategorizedProblem[] problems = parsedUnit.compilationResult().problems;
+ assertNull(problems);
+ } finally {
+ deleteProject("P");
+ }
+ }
+
private void createRuntimeStubs() throws CoreException {
createFolder("/P/org/objectteams");
createFile("/P/org/objectteams/ITeam.java",