Project: AspectJ
Bug 61768 scope for intertype methods
Reported: 2004-05-11 13:35:42 | Status: resolved fixed

/* According to the documentation, the scope rules for intertype method declarations are interpreted from the originating aspect. The only exceptions (I thought) are the use of "this" and "super" which refer to the target type. According to that interpretation, the program below is type correct, but ajc generates two error messages, shown in comments at the relevant lines. Note that it's ok to access private static fields of the aspect, but not to use private classes of the aspect. If this is a feature and not a bug, what are the precise scope rules for intertype method declarations? */ aspect Aspect { private static int y = 5; private class A { int x = 3; } private static void B.happy() { System.out.println(y); // happy accessing private field y } private static void B.foo(A z) { System.out.println(z.x); // ERROR: The type Aspect.A is not visible } public void B.bar() { B.foo(new A()); // ERROR: The type A is not visible } } class B { } public class IT { public static void main(String[] args) { new B().bar(); } }

Files changed in fix:
tests/bugs/oxford/PR61768.java tests/bugs/oxford/PR62475.java tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java