Bug 395746 - [compiler] role of static inner of an inaccessible outer
cannot resolve base methods
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
index 336f502..ec6aba8 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java
@@ -343,7 +343,7 @@
//{ObjectTeams: base imports are collected seperately
if (importReference.isBase()) {
baseImports[baseCount] = importReference;
- Binding importBinding = findImport(compoundName, compoundName.length);
+ Binding importBinding = findImport(compoundName, compoundName.length, true/*allowDecapsulation*/);
if (importBinding.problemId() == ProblemReasons.NotVisible) {
final ReferenceBinding importedType = (ReferenceBinding) ((ProblemReferenceBinding)importBinding).closestMatch();
problemReporter().setRechecker(new IProblemRechecker() {
@@ -701,6 +701,11 @@
}
}
private Binding findImport(char[][] compoundName, int length) {
+//{ObjectTeams: optional third argument:
+ return findImport(compoundName, length, false);
+}
+private Binding findImport(char[][] compoundName, int length, boolean allowDecapsulation) {
+// SH}
recordQualifiedReference(compoundName);
Binding binding = this.environment.getTopLevelPackage(compoundName[0]);
@@ -735,6 +740,9 @@
while (i < length) {
type = (ReferenceBinding)this.environment.convertToRawType(type, false /*do not force conversion of enclosing types*/); // type imports are necessarily raw for all except last
+//{ObjectTeams:
+ if (!allowDecapsulation)
+// SH}
if (!type.canBeSeenBy(this.fPackage))
return new ProblemReferenceBinding(CharOperation.subarray(compoundName, 0, i), type, ProblemReasons.NotVisible);
diff --git a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/PlayedByRelation.java b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/PlayedByRelation.java
index 65dffda..d9f359c 100644
--- a/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/PlayedByRelation.java
+++ b/testplugins/org.eclipse.objectteams.otdt.tests/otjld/org/eclipse/objectteams/otdt/tests/otjld/roleplaying/PlayedByRelation.java
@@ -2643,4 +2643,28 @@
"}\n"
});
}
+
+ // access to private static inner of an inaccessible outer via playedBy
+ public void test2125_roleOfNestedClass1() {
+ runConformTest(
+ new String[] {
+ "p2125/base/T2125ronc1.java",
+ "package p2125.base;\n" +
+ "class T2125ronc1 {\n" +
+ " private static class Inner {\n" +
+ " void foo() {}\n" +
+ " }\n" +
+ " void bar(Inner i) { i.foo(); }\n" +
+ "}\n",
+ "p2125/teams/Team2125ronc1.java",
+ "package p2125.teams;\n" +
+ "import base p2125.base.T2125ronc1.Inner;\n" +
+ "@SuppressWarnings(\"decapsulation\")\n" +
+ "public team class Team2125ronc1 {\n" +
+ " protected class R playedBy Inner {\n" +
+ " void foo() -> void foo();\n" +
+ " }\n" +
+ "}\n"
+ });
+ }
}