[ 
https://issues.apache.org/jira/browse/GROOVY-12059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King resolved GROOVY-12059.
--------------------------------
    Fix Version/s: 6.0.0-alpha-2
       Resolution: Fixed

> 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
>            Priority: Major
>             Fix For: 6.0.0-alpha-2
>
>
> {code:groovy}
> @Requires({ n > 0 }) // okay
> int sqrt(n) { Math.sqrt(n) }
> println sqrt(5) // => 2
> @Requires({ n -> n > 0 }) // expected error <= shouldn't be allowed here
> int sqrt2(n) { Math.sqrt(n) }
> @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)

Reply via email to