Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephan Herrmann2018-02-11 14:07:23 +0000
committerStephan Herrmann2018-02-12 23:40:24 +0000
commit13f941103acfb5f3ad444d847780f2a5f1ff1634 (patch)
tree8af0c76edf8c9316fdbf8b848e3040f6858fe3e4
parentbfa620e9e10a69ba63c011212e3a9863d5ae70a8 (diff)
downloadorg.eclipse.objectteams-13f941103acfb5f3ad444d847780f2a5f1ff1634.tar.gz
org.eclipse.objectteams-13f941103acfb5f3ad444d847780f2a5f1ff1634.tar.xz
org.eclipse.objectteams-13f941103acfb5f3ad444d847780f2a5f1ff1634.zip
Backport Bug 531011 - [otdre] generic callin binding cannot define
parameter mappings - test for secondary NPE plus fix cherry-pick of commit 96006c13f10fb476ec38acafbdffb5789e41ca86
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java6
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/callinbinding/CallinWithTranslation.java42
2 files changed, 46 insertions, 2 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java
index f7288c8e4..90dba0d09 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/mappings/CallinImplementorDyn.java
@@ -669,8 +669,10 @@ public class CallinImplementorDyn extends MethodMappingImplementor {
{
if (isResultBoxed)
result = gen.createUnboxing(result, (BaseTypeBinding) baseReturn);
- Expression mappedResult = new PotentialRoleReceiverExpression(
- callinDecl.getResultExpression(baseSpec, isResultBoxed, gen/*stepOverGen*/),
+ Expression mappedResult = callinDecl.getResultExpression(baseSpec, isResultBoxed, gen/*stepOverGen*/);
+ if (!isStaticRoleMethod)
+ mappedResult = new PotentialRoleReceiverExpression(
+ mappedResult,
roleVar,
gen.typeReference(roleType.getRealClass()));
messageSendStatements = new Statement[] {
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/callinbinding/CallinWithTranslation.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/callinbinding/CallinWithTranslation.java
index dccacd2ae..1933a3652 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/callinbinding/CallinWithTranslation.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/callinbinding/CallinWithTranslation.java
@@ -489,4 +489,46 @@ public class CallinWithTranslation extends AbstractOTJLDTest {
"rm1 t1.MyTeam$__OT__Mid$__OT__R\n" +
"b1.MyBase");
}
+
+ public void testBug531011_secondary() {
+ runNegativeTest(
+ new String[] {
+ "Main.java",
+ "public class Main {\n" +
+ " public static void main(String... args) {\n" +
+ " new t.Team1().activate();\n" +
+ " System.out.print(b.Base.<String>m());\n" +
+ " }\n" +
+ "}\n",
+ "b/Base.java",
+ "package b;\n" +
+ "public class Base {\n" +
+ " public static <T> T m() { return null; }\n" +
+ "}\n",
+ "t/Team1.java",
+ "package t;\n" +
+ "import base b.Base;\n" +
+ "public team class Team1 {\n" +
+ " protected class R playedBy Base {\n" +
+ " R() { base(); }\n" +
+ " <T> T rm() <- replace T m()\n" +
+ " with { result -> result }\n" +
+ " static callin <T> T rm() {\n" +
+ " return base.rm();\n" +
+ " }\n" +
+ " }\n" +
+ "}\n"
+ },
+ "----------\n" +
+ "1. ERROR in t\\Team1.java (at line 6)\n" +
+ " <T> T rm() <- replace T m()\n" +
+ " ^^\n" +
+ "T cannot be resolved to a type\n" +
+ "----------\n" +
+ "2. ERROR in t\\Team1.java (at line 6)\n" +
+ " <T> T rm() <- replace T m()\n" +
+ " ^^\n" +
+ "T cannot be resolved to a type\n" +
+ "----------\n");
+ }
}

Back to the top