Sven created GROOVY-11731:
-----------------------------
Summary: Closure Params FromString
Key: GROOVY-11731
URL: https://issues.apache.org/jira/browse/GROOVY-11731
Project: Groovy
Issue Type: Bug
Reporter: Sven
{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)