From 0e6530f173f186e1668043abeb08df51b593c9de Mon Sep 17 00:00:00 2001 From: aclement Date: Mon, 22 May 2006 10:03:43 +0000 Subject: [PATCH] test for 128443 --- tests/bugs152/pr128443/Bug.java | 23 ++++++++ tests/bugs152/pr128443/Covariance.java | 16 ++++++ .../pr128443/CovariantDeclaredParent.java | 54 +++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 tests/bugs152/pr128443/Bug.java create mode 100644 tests/bugs152/pr128443/Covariance.java create mode 100644 tests/bugs152/pr128443/CovariantDeclaredParent.java diff --git a/tests/bugs152/pr128443/Bug.java b/tests/bugs152/pr128443/Bug.java new file mode 100644 index 000000000..afc95c46f --- /dev/null +++ b/tests/bugs152/pr128443/Bug.java @@ -0,0 +1,23 @@ + + +interface Result {} + +interface Factory { + Result getInstance(); +} + +class B {} + +class D implements Factory {} + +aspect EnsureBImplementsResult { + + // bug: this should work + declare parents: B implements Result; + + + // bug: get error here wrt invalid return type + public B D.getInstance() { + return new B(); + } +} diff --git a/tests/bugs152/pr128443/Covariance.java b/tests/bugs152/pr128443/Covariance.java new file mode 100644 index 000000000..2263c6700 --- /dev/null +++ b/tests/bugs152/pr128443/Covariance.java @@ -0,0 +1,16 @@ +interface Result {} +interface Factory { + Result getInstance(); +} + + +aspect A_forB { + declare parents: B implements Result; + + public B D.getInstance() { + return new B(); + } +} + +class D implements Factory {} +class B {} diff --git a/tests/bugs152/pr128443/CovariantDeclaredParent.java b/tests/bugs152/pr128443/CovariantDeclaredParent.java new file mode 100644 index 000000000..fad498960 --- /dev/null +++ b/tests/bugs152/pr128443/CovariantDeclaredParent.java @@ -0,0 +1,54 @@ +/** + * Declaring class works - see Bug below for declaring interface. + */ +/* +public class CovariantDeclaredParent { + interface Result {} + + public class Super { + public Result result() {return null;} + } + class Sub extends Super { + public C result() { return null; } + } + static aspect A { + declare parents: C implements Result ; + } + class C {} +} +*/ + + +/** + * Declaring interface on type should happen before any + * covariant return types are evaluated. + */ +class Bug { + interface Result {} + interface Factory { + Result getInstance(); + } + // uncomment to get more errors with default implementation +// static aspect A { +// // default implementation +// public Result Factory.getInstance() { +// throw new UnsupportedOperationException(); +// } +// } + + // D is factory for B + static aspect A_forB { + // bug: this should work + declare parents: B implements Result; + // Bug: get error here wrt invalid return type + public B D.getInstance() { + return new B(); + } + } + static class D implements Factory {} + + static class B {} + // to avoid the bug, declare interface directly on class + // static class B implements Result {} + +} -- 2.39.5