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

Eric Milles commented on GROOVY-11731:
--------------------------------------

I don’t have the spec at hand, but FromString is supposed to be supplied a 
single string that indicates the signature. So “Integer,Map<String,Object>” for 
two params. Multiple option values indicate alternate signatures. 

> Closure Params FromString 
> --------------------------
>
>                 Key: GROOVY-11731
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11731
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Sven
>            Priority: Minor
>
> {code:java}
> @CompileStatic
> static void main(String[] args) {
>     test({ int rowNumber, Map<String, Object> currentRow ->
>         // This is a placeholder for the actual logic that would process each 
> row.)
>         println "Row number: $rowNumber"
>         println "Current row: $currentRow"
>     })
> }
> static void test(@ClosureParams(value = FromString, options = ["Integer", 
> "Map<String, Object>"]) Closure closure) {
>     int rowNumber = 0
>     Map <String, Object> currentRow = [:]
>     closure(rowNumber, currentRow)
> } {code}
> The above code works with groovy 3.0.18 and below after that it stops working
> I got it to work like that:
> {code:java}
> @CompileStatic
> static void main(String[] args) {
>     test({ int rowNumber, Map<String, Object> currentRow ->
>         // This is a placeholder for the actual logic that would process each 
> row.)
>         println "Row number: $rowNumber"
>         println "Current row: $currentRow"
>     })
> }
> static void test(@ClosureParams(value = FromString, options = ["Integer, 
> Map<String, Object>"]) Closure closure) {
>     int rowNumber = 0
>     Map <String, Object> currentRow = [:]
>     closure(rowNumber, currentRow)
> }
>  {code}
> But either the doc is wrong or the implementation has a bug.
>  
> The error I get is the following:
> Incorrect number of parameters. Expected 1 but found 2
>  @ line 9, column 10.
>        test({ int rowNumber, Map<String, Object> currentRow ->
>             ^
>  
>  



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

Reply via email to