Bug 198341

Summary: annoated types via declare @type are not always matched in type pattern
Product: [Tools] AspectJ Reporter: Vincenz Braun <vb>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aclement
Version: unspecified   
Target Milestone: 1.6.2   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Vincenz Braun CLA 2007-07-30 21:23:49 EDT
Take this little Test case:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface TestAnnotation1 {}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface TestAnnotation2{}

@TestAnnotation1
public class Annotated {}

public interface Marker {}

public aspect AnnotationAspect {
	
	declare @type: @TestAnnotation1 *: @TestAnnotation2;
	
        // of cource this matches
        // declare parents: (@TestAnnotation1 *)  implements Marker;
        // this matches, too
        // declare parents: (@TestAnnotation2 *)  implements Marker;

        // this does not match on Annotated
	declare parents: (@TestAnnotation2 *) && !java.lang.annotation.Annotation implements Marker;
        // but this does match on annotated
	// declare parents: (@TestAnnotation1 *) && !java.lang.annotation.Annotation implements Marker;
}
Comment 1 Andrew Clement CLA 2008-08-22 17:07:42 EDT
fixed - the implementation of And for type patterns did not defer to its left and right branches when checking whether it represented a '*' annotation pattern.

might still be an issue for ! type patterns involving annotations, but I'll look at that some other time ;)