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

Paul King updated GROOVY-12059:
-------------------------------
    Description: 
{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}

  was:
{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}


> 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
>
> {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