Re: Closures in annotations

2020-11-16 Thread Paul King
I created this: https://issues.apache.org/jira/browse/GROOVY-9817 On Tue, Nov 17, 2020 at 2:11 PM Remko Popma wrote: > Eric and Paul, > Thank you both for your responses! > > Paul, > Thank you for your quick turnaround on supporting array annotations! > > I will create a Jira ticket when I get t

Re: Closures in annotations

2020-11-16 Thread Remko Popma
Eric and Paul, Thank you both for your responses! Paul, Thank you for your quick turnaround on supporting array annotations! I will create a Jira ticket when I get to my PC. Remko > On Nov 17, 2020, at 12:24, Paul King wrote: > >  > The following runs fine after adding in array support: >

Re: Closures in annotations

2020-11-16 Thread Paul King
The following runs fine after adding in array support: import java.lang.annotation.* import org.codehaus.groovy.runtime.InvokerHelper class ClosureTest { static class Demo { @Option(names = "-x", completionCandidates = {["A", "B", "C"]}, converter = [{

Re: Closures in annotations

2020-11-16 Thread Paul King
The Closure to Class conversion doesn't currently support arrays. If you change converter() to take just a single convert, your example works for me. Supporting arrays might be an interesting enhancement. I'll take a look at what would be involved. Cheers, Paul. On Tue, Nov 17, 2020 at 11:02 A

RE: Closures in annotations

2020-11-16 Thread Milles, Eric (TR Technology)
Is there an instance in the core language/runtime where a closure literal is used as part of an annotation but not for an AST transformation? I'm not sure what the compiler does when it encounters a closure expression as the value for an annotation attribute (of type Class). But the AST transf

Re: Closures in annotations

2020-11-16 Thread Remko Popma
I’m probably overlooking something simple but I’m not seeing it yet. The below code demonstrates the issue when trying to pass a Groovy closure to the @Option(converter = ...)attribute: class ClosureTest { static class Demo { @picocli.CommandLine.Option(names = "-x", c

Re: Closures in annotations

2020-11-16 Thread Remko Popma
PS The ITypeConverter interface definition is here: https://picocli.info/apidocs/picocli/CommandLine.ITypeConverter.html On Mon, Nov 16, 2020 at 21:08 Remko Popma wrote: > Hi all, > > I have a question about passing closures to annotations in Groovy. > To illustrate, consider the @Option annot

Closures in annotations

2020-11-16 Thread Remko Popma
Hi all, I have a question about passing closures to annotations in Groovy. To illustrate, consider the @Option annotation in the picocli library. Relevant attributes are `completionCandidates` and `converter`, defined in Java as follows: @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FI