Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2016-11-22 23:20:08 +0000
committerStephan Herrmann2016-11-22 23:22:14 +0000
commitd6ebc185bf0e558e466fbaf5f98af96bd92519e2 (patch)
tree586276f4d65994661255f3c730fbcc7396f2f26a
parentd3c00c34bb9731a1f4d651898afe944aac5027d0 (diff)
downloadorg.eclipse.objectteams-d6ebc185bf0e558e466fbaf5f98af96bd92519e2.tar.gz
org.eclipse.objectteams-d6ebc185bf0e558e466fbaf5f98af96bd92519e2.tar.xz
org.eclipse.objectteams-d6ebc185bf0e558e466fbaf5f98af96bd92519e2.zip
Bug 495624: bogus: "Void methods cannot return a value" in nested
structure inside a callin method
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/control/Dependencies.java2
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/TransformStatementsVisitor.java9
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/callinbinding/CallinMethodBinding.java27
3 files changed, 34 insertions, 4 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/control/Dependencies.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/control/Dependencies.java
index e4ecbce1e..f5fa74b67 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/control/Dependencies.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/control/Dependencies.java
@@ -1960,7 +1960,7 @@ public class Dependencies implements ITranslationStates {
if ((type.bits & ASTNode.IsLocalType) != 0) {
MethodScope methodScope = type.scope.methodScope();
if (methodScope != null)
- transformer.checkPushCallinMethod(methodScope.referenceMethod());
+ transformer.checkPushCallinMethod(methodScope.referenceMethod(), true);
}
type.traverse(transformer, type.scope.compilationUnitScope());
} else if (clazz.isTeam()) {
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/TransformStatementsVisitor.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/TransformStatementsVisitor.java
index 4009b37af..78bbe06aa 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/TransformStatementsVisitor.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/statemachine/transformer/TransformStatementsVisitor.java
@@ -77,6 +77,7 @@ public class TransformStatementsVisitor
// -- fields and methods for scope management ---
private Stack<MethodDeclaration> _methodDeclarationStack = new Stack<MethodDeclaration>();
+ private boolean isLocalTypeInCallin = false;
private WeavingScheme weavingScheme;
@@ -90,11 +91,13 @@ public class TransformStatementsVisitor
* avoid NPEs and spurious error messages.
*
* @param methodDeclaration
+ * @param localInCallin if the method is the enclosing (callin?) method of a local type
*/
- public void checkPushCallinMethod(AbstractMethodDeclaration methodDeclaration) {
+ public void checkPushCallinMethod(AbstractMethodDeclaration methodDeclaration, boolean localInCallin) {
if ( isGoodCallin(methodDeclaration))
{
this._methodDeclarationStack.push((MethodDeclaration)methodDeclaration);
+ this.isLocalTypeInCallin = localInCallin;
}
}
@@ -209,7 +212,7 @@ public class TransformStatementsVisitor
/** May need to 'generalize' a return expression. */
@Override
public boolean visit(ReturnStatement returnStatement, BlockScope scope) {
- if (this._methodDeclarationStack.isEmpty())
+ if (this._methodDeclarationStack.isEmpty() || this.isLocalTypeInCallin)
return true;
MethodDeclaration methodDecl = this._methodDeclarationStack.peek();
if (!isGoodCallin(methodDecl))
@@ -239,7 +242,7 @@ public class TransformStatementsVisitor
@Override
public boolean visit(MethodDeclaration methodDeclaration, ClassScope scope) {
methodDeclaration.bits |= ASTNode.HasBeenTransformed;
- checkPushCallinMethod(methodDeclaration);
+ checkPushCallinMethod(methodDeclaration, false);
return true;
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/callinbinding/CallinMethodBinding.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/callinbinding/CallinMethodBinding.java
index 1cf02d6d5..42e3b17c1 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/callinbinding/CallinMethodBinding.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/callinbinding/CallinMethodBinding.java
@@ -8360,4 +8360,31 @@ public class CallinMethodBinding extends AbstractOTJLDTest {
},
"exdone");
}
+
+ public void testBug495624() {
+ runConformTest(
+ new String[] {
+ "test495624/MyTeam.java",
+ "package test495624;\n" +
+ "public team class MyTeam {\n" +
+ " protected class R {\n" +
+ " callin void ci(final boolean b1, final boolean b2) {\n" +
+ " base.ci(b1,b2);\n" +
+ " new Runnable() {\n" +
+ " public void run() {\n" +
+ " if (b1) {\n" +
+ " if (b2)\n" +
+ " return; // (1)\n" +
+ " else\n" +
+ " return; // (2)\n" +
+ " }\n" +
+ " }\n" +
+ " }.run();\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "");
+
+ }
}

Back to the top