diff options
author | Stephan Herrmann | 2016-11-26 15:50:45 +0000 |
---|---|---|
committer | Stephan Herrmann | 2016-11-26 15:50:45 +0000 |
commit | 157306d7120e2ce37d7d11294fab7c1a538877d6 (patch) | |
tree | de719e11deadd56ed152195bd693a3a19d3cba25 | |
parent | d6ebc185bf0e558e466fbaf5f98af96bd92519e2 (diff) | |
download | org.eclipse.objectteams-157306d7120e2ce37d7d11294fab7c1a538877d6.tar.gz org.eclipse.objectteams-157306d7120e2ce37d7d11294fab7c1a538877d6.tar.xz org.eclipse.objectteams-157306d7120e2ce37d7d11294fab7c1a538877d6.zip |
Bug 506749: ClassCastException in
BaseAllocationExpression.internalCheckGenerate
3 files changed, 48 insertions, 2 deletions
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 e6c5857da..e5e0b3e23 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 @@ -11270,9 +11270,13 @@ public void baseConstructorCallInWrongMethod( ((AbstractMethodDeclaration)enclosingMethod).binding.readableName()); else arguments[0] = new String(((AbstractMethodDeclaration)enclosingMethod).selector); - else + else if (this.referenceContext instanceof TypeDeclaration) arguments[0] = "<clinit> of "+ //$NON-NLS-1$ new String(((TypeDeclaration)this.referenceContext).binding.readableName()); + else if (this.referenceContext instanceof LambdaExpression) + arguments[0] = this.referenceContext.toString(); + else + arguments[0] = "<unexpected source location>"; //$NON-NLS-1$ this.handle( IProblem.BaseCtorInWrongMethod, 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 4953d1861..ac6a1066b 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 @@ -1018,7 +1018,7 @@ 1204101 = Cannot invoke the lifting constructor {0} to create an externalized role (OTJLD 2.4.1(a)). 1204102 = Argument to lifting constructor {0} is not a freshly created base object (of type {1}); may cause a DuplicateRoleException at runtime (OTJLD 2.4.1(c)). -1204201 = Illegal base constructor call: method {0} is not a constructor of a bound role (OTJLD 2.4.2). +1204201 = Illegal base constructor call: enclosing ''{0}'' is not a constructor of a bound role (OTJLD 2.4.2). 1204202 = Illegal call to base constructor: this constructor is a lifting constructor (OTJLD 2.4.2). 1204203 = Cannot use this constructor from class {0}, because it creates a base instance of type {2} wheras a base instance of type {1} is required (OTJLD 2.4.2(c)). 1204204 = Constructor call (tsuper) must be the first statement in a role constructor (OTJLD 2.4.2). diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java index b3fade6a4..f9ec7003f 100644 --- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java +++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/other/Java8.java @@ -415,4 +415,46 @@ public class Java8 extends AbstractOTJLDTest { true, // flush options); } + + public void testBug506749a() { + runNegativeTest( + new String[] { + "Bug506749.java", + "public team class Bug506749 {\n" + + " protected class R {\n" + + " void test() {\n" + + " Runnable r = () -> base();\n" + + " }\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in Bug506749.java (at line 4)\n" + + " Runnable r = () -> base();\n" + + " ^^^^\n" + + "Illegal base constructor call: enclosing '() -> <no expression yet>' is not a constructor of a bound role (OTJLD 2.4.2).\n" + + "----------\n"); + } + + public void testBug506749b() { + runNegativeTest( + new String[] { + "Bug506749.java", + "public team class Bug506749 {\n" + + " protected class R {\n" + + " void test() {\n" + + " Runnable r = () -> { base(); };\n" + + " }\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in Bug506749.java (at line 4)\n" + + " Runnable r = () -> { base(); };\n" + + " ^^^^\n" + + "Illegal base constructor call: enclosing \'() -> {\n" + + " <no expression yet>;\n" + + "}\' is not a constructor of a bound role (OTJLD 2.4.2).\n" + + "----------\n"); + } } |