diff options
author | Stephan Herrmann | 2011-12-13 19:44:33 +0000 |
---|---|---|
committer | Stephan Herrmann | 2011-12-13 19:46:00 +0000 |
commit | 0f8bfbbc9ae90550f9f4eb049f43a7c1d0dc568f (patch) | |
tree | 9ba66d08c43a19e714aac0c3216a50ca7c004bc6 | |
parent | 821b21e09d2be0faa729311712d5420d7a9df417 (diff) | |
download | org.eclipse.objectteams-0f8bfbbc9ae90550f9f4eb049f43a7c1d0dc568f.tar.gz org.eclipse.objectteams-0f8bfbbc9ae90550f9f4eb049f43a7c1d0dc568f.tar.xz org.eclipse.objectteams-0f8bfbbc9ae90550f9f4eb049f43a7c1d0dc568f.zip |
Test & fix for Bug 366597 - [compiler] NPE with role ifc wronglyreleases/OTDT_2.1M4builds/201112131519
interpreted as a team
3 files changed, 97 insertions, 3 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java index 2cec1dcf4..6de353ae5 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java @@ -997,6 +997,10 @@ public class ClassScope extends Scope { problemReporter().illegalModifierForAnnotationMemberType(sourceType); else problemReporter().illegalModifierForMemberInterface(sourceType); +//{ObjectTeams: prevent downstream problems with types illegally marked as team: + modifiers &= ~ClassFileConstants.AccTeam; + this.referenceContext.modifiers &= ~ClassFileConstants.AccTeam; +// SH} } /* } else if (sourceType.isLocalType()) { //interfaces cannot be defined inside a method diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/Protections.java b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/Protections.java index 42c17d7d5..ffc1867af 100644 --- a/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/Protections.java +++ b/org.eclipse.jdt.core/compiler/org/eclipse/objectteams/otdt/internal/core/compiler/util/Protections.java @@ -84,8 +84,10 @@ public class Protections implements ClassFileConstants, ExtraCompilerModifiers { if (!hasClassKindProblem(type.binding)) scope.problemReporter().missingTeamForRoleWithMembers(type.binding, type.memberTypes[0]); // avoid secondary errors - modifiers |= AccTeam; - type.modifiers |= AccTeam; + if (!type.isInterface()) { // setting AccTeam for interface would aggravate the situation + modifiers |= AccTeam; + type.modifiers |= AccTeam; + } type.binding.tagBits |= TagBits.HasClassKindProblem; type.getTeamModel(); // initialize for (int i = 0; i < type.memberTypes.length; i++) { diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java index 1310815cd..1501ff2df 100644 --- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java +++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/regression/ReportedBugs.java @@ -39,7 +39,7 @@ public class ReportedBugs extends AbstractOTJLDTest { // Static initializer to specify tests subset using TESTS_* static variables // All specified tests which does not belong to the class are skipped... static { -// TESTS_NAMES = new String[] { "testB11_sh75"}; +// TESTS_NAMES = new String[] { "testB11_sh9"}; // TESTS_NUMBERS = new int[] { 1459 }; // TESTS_RANGE = new int[] { 1097, -1 }; } @@ -4430,6 +4430,94 @@ public class ReportedBugs extends AbstractOTJLDTest { false/*showWarningToken*/); } + // Bug 366597 - [compiler] NPE with role ifc wrongly interpreted as a team + public void testB11_sh97() { + runNegativeTest(new String[] { + "t/T1.java", + "package t;\n" + + "import base b.Base;\n" + + "public team class T1 {\n" + + " protected interface IR\n" + + " public class R2 playedBy Base {\n" + + " void bar() {\n" + + " this.foo();\n" + + " }\n" + + " }\n" + + "}\n", + "b/Base.java", + "package b;\n" + + "public class Base { void foo() {} }\n" + }, + "----------\n" + + "1. ERROR in t\\T1.java (at line 4)\n" + + " protected interface IR\n" + + " ^^\n" + + "Syntax error, insert \"InterfaceBody\" to complete ClassBodyDeclarations\n" + + "----------\n" + + "2. ERROR in t\\T1.java (at line 5)\n" + + " public class R2 playedBy Base {\n" + + " ^^\n" + + "Member types not allowed in regular roles. Mark class t.T1.IR as a team if R2 should be its role (OTJLD 1.5(a,b)). \n" + + "----------\n" + + "3. ERROR in t\\T1.java (at line 7)\n" + + " this.foo();\n" + + " ^^^^\n" + + "Missing anchor (team instance) for role type t.T1.IR.R2 outside its team context (OTJLD 1.2.2(b)).\n" + + "----------\n" + + "4. WARNING in t\\T1.java (at line 7)\n" + + " this.foo();\n" + + " ^^^^^^^^^^\n" + + "Access restriction of method foo() in type b.Base is overridden by this method binding (OTJLD 3.4(a)).\n" + + "----------\n" + + "5. ERROR in t\\T1.java (at line 7)\n" + + " this.foo();\n" + + " ^^^^^^^^^^\n" + + "Unresolved self call foo() is implicitly bound by an inferred callout (OTJLD 3.1(j)).\n" + + "----------\n"); + } + + // Bug 366597 - [compiler] NPE with role ifc wrongly interpreted as a team + public void testB11_sh98() { + runNegativeTest(new String[] { + "t/T1.java", + "package t;\n" + + "import base b.Base;\n" + + "public team class T1 extends T0 {\n" + + " protected team interface IR {}\n" + + " @Override\n" + + " protected class R2 playedBy Base {\n" + + " void bar() {\n" + + " this.foo();\n" + + " }\n" + + " }\n" + + "}\n", + "t/T0.java", + "package t;\n" + + "public team class T0 {\n" + + " protected class R2 {}" + + "}\n", + "b/Base.java", + "package b;\n" + + "public class Base { void foo() {} }\n" + }, + "----------\n" + + "1. ERROR in t\\T1.java (at line 4)\n" + + " protected team interface IR {}\n" + + " ^^\n" + + "Illegal modifier for the member interface IR; only public, protected, private, static & abstract are permitted\n" + + "----------\n" + + "2. WARNING in t\\T1.java (at line 8)\n" + + " this.foo();\n" + + " ^^^^^^^^^^\n" + + "Access restriction of method foo() in type b.Base is overridden by this method binding (OTJLD 3.4(a)).\n" + + "----------\n" + + "3. ERROR in t\\T1.java (at line 8)\n" + + " this.foo();\n" + + " ^^^^^^^^^^\n" + + "Unresolved self call foo() is implicitly bound by an inferred callout (OTJLD 3.1(j)).\n" + + "----------\n"); + } + // reported by Christine Hundt // B.1.1-otjld-ju-1 public void testB11_ju1() { |