diff options
author | acolyer <acolyer> | 2005-09-08 13:40:33 +0000 |
---|---|---|
committer | acolyer <acolyer> | 2005-09-08 13:40:33 +0000 |
commit | 2505485766b460041f2648e56f34132982f6428a (patch) | |
tree | 0f3eec6e8fd58dbb652ceffb155873e3b20c54ee | |
parent | 9fa1e7af8353a15a5f28f1bb1a4c4684a3c38eae (diff) | |
download | aspectj-2505485766b460041f2648e56f34132982f6428a.tar.gz aspectj-2505485766b460041f2648e56f34132982f6428a.zip |
tests and fix for pr108902 and pr108903
-rw-r--r-- | org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java | 11 | ||||
-rw-r--r-- | tests/bugs150/pr108902/GenericTypeMismatch.aj | 12 | ||||
-rw-r--r-- | tests/bugs150/pr108902/Observer.java | 5 | ||||
-rw-r--r-- | tests/bugs150/pr108902/ObserverProtocol.aj | 48 | ||||
-rw-r--r-- | tests/bugs150/pr108902/Subject.java | 7 | ||||
-rw-r--r-- | tests/bugs150/pr108903.aj | 17 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java | 7 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc150/ajc150.xml | 11 |
8 files changed, 117 insertions, 1 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java index 666335db7..859704441 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java @@ -103,12 +103,21 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration { if (((declaredModifiers & AccAbstract) != 0)) scope.problemReporter().methodNeedingNoBody(this); } + + // XXX AMC we need to do this, but I'm not 100% comfortable as I don't + // know why the return type is wrong in this case. Also, we don't seem to need + // to do it for args... + if (munger.getSignature().getReturnType().isRawType()) { + if (!binding.returnType.isRawType()) { + EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(scope); + binding.returnType = world.makeTypeBinding(munger.getSignature().getReturnType()); + } + } // check @Override annotation - based on MethodDeclaration.resolveStatements() @Override processing checkOverride: { if (this.binding == null) break checkOverride; if (this.scope.compilerOptions().sourceLevel < JDK1_5) break checkOverride; - int bindingModifiers = this.binding.modifiers; boolean hasOverrideAnnotation = (this.binding.tagBits & TagBits.AnnotationOverride) != 0; // Need to verify diff --git a/tests/bugs150/pr108902/GenericTypeMismatch.aj b/tests/bugs150/pr108902/GenericTypeMismatch.aj new file mode 100644 index 000000000..4678baae0 --- /dev/null +++ b/tests/bugs150/pr108902/GenericTypeMismatch.aj @@ -0,0 +1,12 @@ +import java.util.*; + +abstract aspect ObserverProtocol { + + private Collection Subject.observers = new ArrayList(); + + public Collection Subject.getObservers() { + return observers; + } +} + +aspect XYZ extends ObserverProtocol {}
\ No newline at end of file diff --git a/tests/bugs150/pr108902/Observer.java b/tests/bugs150/pr108902/Observer.java new file mode 100644 index 000000000..b055f8484 --- /dev/null +++ b/tests/bugs150/pr108902/Observer.java @@ -0,0 +1,5 @@ +//Observer.java +interface Observer +{ + public void update(); +}
\ No newline at end of file diff --git a/tests/bugs150/pr108902/ObserverProtocol.aj b/tests/bugs150/pr108902/ObserverProtocol.aj new file mode 100644 index 000000000..93750cc87 --- /dev/null +++ b/tests/bugs150/pr108902/ObserverProtocol.aj @@ -0,0 +1,48 @@ +import java.util.*; +//ObserverProtocol +public abstract aspect ObserverProtocol{ + abstract pointcut stateChange(Subject subject); + + after(Subject subject):stateChange(subject){ + Iterator it=subject.getObservers().iterator(); + while(it.hasNext()){ + Observer observer=(Observer)it.next(); + observer.update(); + } + } + + private Collection Subject.observers=new ArrayList(); + + public void Subject.addObserver(Observer observer){ + observers.add(observer); + } + + public void Subject.removeObserver(Observer observer){ + observers.remove(observer); + } + + public Collection Subject.getObservers() + { + return observers; + } + + public void Subject.setObservers(Collection c) { + observers = c; + } + + private Collection myCollection = new ArrayList(); + + public Collection returnsCollectionMethod() { return myCollection; } + + public Collection C1.getCollection() { + return aCollection; + } + + public void C1.setCollection(Collection c) { + aCollection = c; + } +} + +class C1 { + public Collection aCollection; +}
\ No newline at end of file diff --git a/tests/bugs150/pr108902/Subject.java b/tests/bugs150/pr108902/Subject.java new file mode 100644 index 000000000..abdd18743 --- /dev/null +++ b/tests/bugs150/pr108902/Subject.java @@ -0,0 +1,7 @@ +import java.util.*; +//Subject.java +interface Subject { + public void addObserver(Observer observer); + public void removeObserver(Observer observer); + public Collection getObservers(); +}
\ No newline at end of file diff --git a/tests/bugs150/pr108903.aj b/tests/bugs150/pr108903.aj new file mode 100644 index 000000000..099e70c5d --- /dev/null +++ b/tests/bugs150/pr108903.aj @@ -0,0 +1,17 @@ +abstract class Order { + + public void print() { } +} +// +class SalesOrder { +} +// +abstract aspect OrderDecorator +{ + declare parents : SalesOrder extends Order; + public void SalesOrder.print() + { + super.print(); // Line 12 + } + protected pointcut print(Order order) : target(order) && call(public void print()); +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index b48c4c60b..fd2c8a329 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -398,6 +398,13 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("advising cflow advice execution"); } + public void testNoTypeMismatchOnSameGenericTypes() { + runTest("no type mismatch on generic types in itds"); + } + + public void testSuperCallInITD() { + runTest("super call in ITD"); + } // helper methods..... public SyntheticRepository createRepos(File cpentry) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 7849cde7a..fbec23663 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -505,6 +505,17 @@ <compile files="pr108816.aj" > </compile> </ajc-test> + + <ajc-test dir="bugs150/pr108902" pr="108902" title="no type mismatch on generic types in itds"> + <compile files="Subject.java,Observer.java,ObserverProtocol.aj" > + </compile> + </ajc-test> + + <ajc-test dir="bugs150" pr="108903" title="super call in ITD"> + <compile files="pr108903.aj" > + <message kind="error" line="14" text="The method print() is undefined for the type Object"/> + </compile> + </ajc-test> <!-- ============================================================================ --> <!-- ============================================================================ --> |