Paul King created GROOVY-12059:
----------------------------------
Summary: groovy-contracts: support nested closures in contract
annotations
Key: GROOVY-12059
URL: https://issues.apache.org/jira/browse/GROOVY-12059
Project: Groovy
Issue Type: Bug
Reporter: Paul King
Assignee: Paul King
{code:groovy}
@groovy.contracts.Requires({ n > 0 }) // okay
int sqrt(n) { Math.sqrt(n) }
println sqrt(5) // => 2
@groovy.contracts.Requires({ n -> n > 0 }) // expected error <= shouldn't be
allowed here
int sqrt2(n) { Math.sqrt(n) }
@groovy.contracts.Requires({ ns.indices.every{ ns[it] > 0 } }) //
[groovy-contracts] Access to 'it' is not supported. <= should be allowed here
int[] sqrtAll(int[] ns) { ns.collect{ n -> Math.sqrt(n) } }
println sqrtAll([5, 8, 10] as int[]) // => [2, 2, 3]
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)