Project: AspectJ
Bug 123553 Can't use named pointcut in advice decl. in generic aspect
Reported: 2006-01-12 00:56:24 | Status: resolved fixed

When defining a generic aspect with a paramterized PC, using that PC in an advice declaration causes an 'incompatible type' error. Example: public abstract aspect GenericAspect<Par1> { abstract pointcut checkpoint(Par1 par1); // advice declaration causes error after(Par1 par1): checkpoint(par1) {// do something} } Using 1.3.0.20051220093604 and AspectJ 1.5.0, the compiler complains: "incompatible type, expected java.lang.Object found BindingTypePattern(TPar1;, 0). Check the type specified in your pointcut" Since it is possible to paramterize a named PC in subaspects: public abstract aspect GenericAspect<Par1> { abstract pointcut checkpoint(Par1 par1); } public aspect SubAspect1 extends GenericAspect<Main>{ pointcut checkpoint(Main main): call(void Main.test()) && target(main); after (Main main): checkpoint(main) { System.out.println("Caught by 1."); } } public aspect SubAspect2 extends GenericAspect<Main2>{ pointcut checkpoint(Main2 main): call(void Main2.test()) && target(main); after (Main2 main): checkpoint(main) { System.out.println("Caught by 2."); } } ... and since it is possible to use generic PC utilizing unnamed PCs in a generic aspect: public abstract aspect GenericAspect<Par1> { // works after(Par1 par1): call(void Par1.test()) && target(par1) {// something } } ... it seems that this is a bug.

Files changed in fix:
tests/bugs151/pr123553/A.java tests/src/org/aspectj/systemtest/ajc151/Ajc151Tests.java