aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs152
diff options
context:
space:
mode:
authoraclement <aclement>2006-05-22 10:03:43 +0000
committeraclement <aclement>2006-05-22 10:03:43 +0000
commit0e6530f173f186e1668043abeb08df51b593c9de (patch)
tree589f226c45f8fa3b8bd6cd810860169c826f32fc /tests/bugs152
parent054eb78c6697e95d28b36b6bb966068fc1f0d5c6 (diff)
downloadaspectj-0e6530f173f186e1668043abeb08df51b593c9de.tar.gz
aspectj-0e6530f173f186e1668043abeb08df51b593c9de.zip
test for 128443
Diffstat (limited to 'tests/bugs152')
-rw-r--r--tests/bugs152/pr128443/Bug.java23
-rw-r--r--tests/bugs152/pr128443/Covariance.java16
-rw-r--r--tests/bugs152/pr128443/CovariantDeclaredParent.java54
3 files changed, 93 insertions, 0 deletions
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 {}
+
+}