diff options
author | acolyer <acolyer> | 2004-08-11 16:51:24 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2004-08-11 16:51:24 +0000 |
commit | 8c5d743c848479b07f3d35479292002aa01b4f70 (patch) | |
tree | d45d6cb11784370946a95dd77c9b50b7e2c89ae0 /tests/bugs | |
parent | d43a39103f476d95cade6b87b604ee4578de25b3 (diff) | |
download | aspectj-8c5d743c848479b07f3d35479292002aa01b4f70.tar.gz aspectj-8c5d743c848479b07f3d35479292002aa01b4f70.zip |
fix for Bugzilla Bug 61768
scope for intertype methods
Diffstat (limited to 'tests/bugs')
-rw-r--r-- | tests/bugs/oxford/ITDScope.aj | 18 | ||||
-rw-r--r-- | tests/bugs/oxford/PR61768.java | 56 | ||||
-rw-r--r-- | tests/bugs/oxford/PR62475.java | 14 |
3 files changed, 76 insertions, 12 deletions
diff --git a/tests/bugs/oxford/ITDScope.aj b/tests/bugs/oxford/ITDScope.aj new file mode 100644 index 000000000..cf49a2fa8 --- /dev/null +++ b/tests/bugs/oxford/ITDScope.aj @@ -0,0 +1,18 @@ +class C { + + static int static_c = 0; + int c = 0; + +} + +aspect A { + static int static_a = 0; + int a = 0; + + private void C.itdFromA() { + c = 1; // ok + static_c = 1; // not ok - use C.static_c; + static_a = 1; // ok + a = 1; // not ok + } +}
\ No newline at end of file diff --git a/tests/bugs/oxford/PR61768.java b/tests/bugs/oxford/PR61768.java new file mode 100644 index 000000000..eca26e215 --- /dev/null +++ b/tests/bugs/oxford/PR61768.java @@ -0,0 +1,56 @@ +/* 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 class A2 {} + + 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); + } + + private static void B.foo2(A2 z) { + System.out.println(z); + } + + public void B.bar() { + B.foo(new A()); // CE L37 : no enclosing instance + } + + public void B.bar2() { + B.foo2(new A2()); + } + +} + +class B { +} + +class IT { + + + public static void main(String[] args) { +new B().bar(); + } + +}
\ No newline at end of file diff --git a/tests/bugs/oxford/PR62475.java b/tests/bugs/oxford/PR62475.java index 3e29ffb0a..993dbc4cc 100644 --- a/tests/bugs/oxford/PR62475.java +++ b/tests/bugs/oxford/PR62475.java @@ -1,18 +1,8 @@ -/* -Intertype field initialisers should be resolved in the aspect -(lexical scope), for consistency with intertype method and -constructor bodies. - -The program below compiles without warning, however, binding z -to the z field of the target class. -*/ - - aspect Aspect { - public int A.x = z; // CE L14 error: z not visible. - + public int A.x = z; // okay, z is visible. + } class A { |