--- /dev/null
+class A {
+
+
+
+}
+
+class B extends A {
+
+ protected void foo() {}
+
+}
+
+class C extends B {}
+
+
+class D extends C {
+
+ public void foo() {}
+
+}
+
+aspect X {
+
+ private void A.foo() {}
+
+ void bar() {
+ D d = new D();
+ d.foo();
+ }
+
+ declare warning : call(* B.foo()) : "should match";
+ declare warning : call(* A.foo()) : "should not match";
+
+}
\ No newline at end of file
--- /dev/null
+package pkg1;
+
+public class A {
+
+ //public void foo() {}
+
+}
\ No newline at end of file
--- /dev/null
+package pkg1;
+
+public class B {}
\ No newline at end of file
--- /dev/null
+package pkg1;
+
+public class C {
+
+ public void foo() {}
+
+}
\ No newline at end of file
--- /dev/null
+package pkg2;
+import pkg1.*;
+
+public aspect ITDInDiffPackage {
+
+ void B.foo() {}
+
+ void bar() {
+ C c = new C();
+ c.foo();
+ }
+
+ declare warning : call(* B.foo()) : "should not match";
+ declare warning : call(* C.foo()) : "should match";
+
+
+}
\ No newline at end of file
--- /dev/null
+class A {
+
+ private void foo() {}
+
+}
+
+class B extends A {
+
+ protected void foo() {}
+
+}
+
+class C extends B {}
+
+
+class D extends C {
+
+ public void foo() {}
+
+}
+
+aspect X {
+
+ void bar() {
+ D d = new D();
+ d.foo();
+ }
+
+ declare warning : call(* B.foo()) : "should match";
+ declare warning : call(* A.foo()) : "should not match";
+
+}
\ No newline at end of file
runTest("inlined field access in proceed call");
}
+ public void testVisibiltyInSignatureMatchingWithOverridesPart1() {
+ runTest("visibility in signature matching with overrides - 1");
+ }
+
+ public void testVisibiltyInSignatureMatchingWithOverridesPart2() {
+ runTest("visibility in signature matching with overrides - 2");
+ }
+
+ public void testVisibiltyInSignatureMatchingWithOverridesPart3() {
+ runTest("visibility in signature matching with overrides - 3");
+ }
+
// helper methods.....
public SyntheticRepository createRepos(File cpentry) {
</compile>
</ajc-test>
+ <ajc-test dir="bugs150/pr71159" pr="71159" title="visibility in signature matching with overrides - 1">
+ <compile files="pr71159.aj">
+ <message kind="warning" line="26" text="should match"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs150/pr71159" pr="71159" title="visibility in signature matching with overrides - 2">
+ <compile files="PrivateITD.aj">
+ <message kind="warning" line="28" text="should match"/>
+ </compile>
+ </ajc-test>
+
+ <ajc-test dir="bugs150/pr71159" pr="71159" title="visibility in signature matching with overrides - 3">
+ <compile files="pkg1/A.java,pkg1/B.java,pkg1/C.java,pkg2/ITDInDiffPackage.aj">
+ <message kind="warning" line="10" text="should match"/>
+ </compile>
+ </ajc-test>
+
<!-- ============================================================================ -->
<!-- ============================================================================ -->
if (!typesAlreadyVisited.contains(toLookIn)) {
typesAlreadyVisited.add(toLookIn);
ResolvedMemberImpl foundMember = (ResolvedMemberImpl) toLookIn.lookupResolvedMember(memberToMatch);
- if (foundMember != null) {
+ if (foundMember != null && isVisibleTo(memberToMatch,foundMember)) {
List declaringTypes = new ArrayList();
// declaring type can be unresolved if the member can from an ITD...
ResolvedType resolvedDeclaringType = foundMember.getDeclaringType().resolve(toLookIn.getWorld());
}
}
+ /**
+ * Returns true if the parent member is visible to the child member
+ * In the same declaring type this is always true, otherwise if parent is private
+ * it is false.
+ * @param childMember
+ * @param parentMember
+ * @return
+ */
+ private static boolean isVisibleTo(ResolvedMember childMember, ResolvedMember parentMember) {
+ if (childMember.getDeclaringType().equals(parentMember.getDeclaringType())) return true;
+ if (Modifier.isPrivate(parentMember.getModifiers())) {
+ return false;
+ } else {
+ return true;
+ }
+ }
// ----