moonfruit opened a new pull request #1339:
URL: https://github.com/apache/groovy/pull/1339
Support `useAs` for `@NamedVariant`
For example:
```groovy
@NamedVariant
void run(int number) {
println(number)
}
```
If we called this method with
```groovy
run(number: "123")
```
Groovy will throw out
```
groovy.lang.MissingMethodException: No signature of method:
ideaGroovyConsole.run() is applicable for argument types: (String) values: [123]
```
After support `useAs`, we can define method like this:
```groovy
@NamedVariant(useAs = true)
void run(int number) {
println(number)
}
```
The generated method will automatically use the operator `as` convert
`String` to `int`, and the will succeed now.
And in order to make the operator `as` work correctly, I also disable
`@CompileStatic` for the generated method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]