diff options
Diffstat (limited to 'tests/java5/covariance/ajdk/AJDKExamples.aj')
-rw-r--r-- | tests/java5/covariance/ajdk/AJDKExamples.aj | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/java5/covariance/ajdk/AJDKExamples.aj b/tests/java5/covariance/ajdk/AJDKExamples.aj new file mode 100644 index 000000000..e7cb02383 --- /dev/null +++ b/tests/java5/covariance/ajdk/AJDKExamples.aj @@ -0,0 +1,47 @@ +public aspect AJDKExamples { + + declare warning : call(* whoAreYou()) + : "call(* whoAreYou())"; + + declare warning : call(* A.whoAreYou()) + : "call(* A.whoAreYou())"; + + declare warning : call(A whoAreYou()) + : "call(A whoAreYou())"; + + declare warning : call(A B.whoAreYou()) + : "call(A B.whoAreYou())"; + + declare warning : call(A+ B.whoAreYou()) + : "call(A+ B.whoAreYou())"; + + declare warning : call(B A.whoAreYou()) + : "call(B A.whoAreYou())"; + + declare warning : call(B whoAreYou()) + : "call(B whoAreYou())"; + + declare warning : call(B B.whoAreYou()) + : "call(B B.whoAreYou())"; + +} + +class A { + public A whoAreYou() { return this; } +} + +class B extends A { + // override A.whoAreYou *and* narrow the return type. + public B whoAreYou() { return this; } +} + +class C { + + public C() { + A a = new A(); + B b = new B(); + a.whoAreYou(); + b.whoAreYou(); + } + +}
\ No newline at end of file |