[ https://issues.apache.org/jira/browse/GROOVY-11311?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17820629#comment-17820629 ]
Jochen Theodorou commented on GROOVY-11311: ------------------------------------------- >From a dynamic Groovy only perspective the call methods are usually not even >called for generated closures. Instead we call directly the doCall methods. >The call methods are just helpers for calls made from Java. So I expect all >important information to be on them. >From a static Groovy perspective we know at compile time of course only the >call methods call(), call(Object) and call(Object[]). They may do dynamic >method calls to the real doCall methods. Of course this does not provide any >type safety because for {int i ->i} we have a doCall(int) method, but also a >call() method, which would fail if called. for {int i=1 ->i} we have of course >two doCall methods doCall() and doCall(int), now call() is ok. call("foo") or >call(1,2,3) is of course still not ok and will fail at runtime. We can >overwrite the call methods to do direct method calls and safe the dynamic >invocation, but I would still not add the annotation decorators there. > Groovy Closure not retaining param annotations, but only for the default > single object param case > ------------------------------------------------------------------------------------------------- > > Key: GROOVY-11311 > URL: https://issues.apache.org/jira/browse/GROOVY-11311 > Project: Groovy > Issue Type: Bug > Affects Versions: 3.0.8, 4.0.4 > Reporter: Val E > Assignee: Eric Milles > Priority: Minor > Attachments: ClosureAnnotationsTest.groovy > > > In trying to process Groovy closure param annotations, via Java reflection, I > realized that there is one narrow case where the param annotations are not > preserved in the generated call method. > This happens only for the case of a single Object param type. All other > variations retain the annotation, it can be a single param of a different > type, or multiple params of Object type. I think this may have something to > do with handling the default 'it' param > ex: > {code:java} > {@TESTANNO def x-> } //wont retain @TESTANNO > {code} > {code:java} > {@TESTANNO Object x-> } //wont retain @TESTANNO > {code} > {code:java} > {@TESTANNO Integer x-> } //will retain @TESTANNO > {code} > {code:java} > {@TESTANNO def x, @TESTANNO def y-> }//will retain @TESTANNO on both x and y > {code} > > Attached a basic groovy script to demonstrate. > -- This message was sent by Atlassian Jira (v8.20.10#820010)