[ 
https://issues.apache.org/jira/browse/GROOVY-7667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17761848#comment-17761848
 ] 

Eric Milles commented on GROOVY-7667:
-------------------------------------

If you do something like this:
{code:groovy}
@A
@B
@AnnotationCollector
@Target(ElementType.ANNOTAITON)
@Retention(RetentionPolicy.CLASS)
public @interface C {
}
{code}

Only the annotations before the {{@AnnotationCollector}} should be collected.  
This is described in the docs very briefly.  
https://github.com/apache/groovy/blob/5c6644bfe30c130af6d734bf6b371a2259efe10d/src/main/java/groovy/transform/AnnotationCollector.java#L148

An example is Immutable: 
https://github.com/apache/groovy/blob/5c6644bfe30c130af6d734bf6b371a2259efe10d/src/main/groovy/groovy/transform/Immutable.groovy#L200

> AnnotationCollector should disregard @Target and @Retention
> -----------------------------------------------------------
>
>                 Key: GROOVY-7667
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7667
>             Project: Groovy
>          Issue Type: Improvement
>    Affects Versions: 2.4.5
>            Reporter: Christopher Smith
>            Priority: Minor
>              Labels: annotations
>
> I attempted to set up an annotation-inheritance situation using 
> {{@AnnotationCollector}}, and I wrote the intermediate collector in Java. 
> Since the intermediate collector was applied to my leaf collector, I put 
> {{@Target(ElementType.ANNOTATION_TYPE)}} on the intermediate collector, but 
> it appears that Groovy copied that annotation to the final target class, 
> where it wasn't allowed and produced a compiler error.
> I suggest that {{@Target}} and {{@Retention}} should be specifically ignored 
> when added to a collector annotation.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to