[jira] [Commented] (GROOVY-8845) @DelegatesTo works only for the first vararg

2020-06-21 Thread Eric Milles (Jira)


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

Eric Milles commented on GROOVY-8845:
-

GROOVY-6022 seems to suggest that a compiler error should be emitted for 
@DelegatesTo applied to array (aka varargs parameter).

> @DelegatesTo works only for the first vararg
> 
>
> Key: GROOVY-8845
> URL: https://issues.apache.org/jira/browse/GROOVY-8845
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.3
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:groovy}
> def md(@DelegatesTo.Target Object target, @DelegatesTo(strategy = 
> Closure.DELEGATE_FIRST) Closure... arg) {
> for (Closure a : arg) {
> a.delegate = target
> a.resolveStrategy = Closure.DELEGATE_FIRST
> a()
> }
> }
> class D {
>   def foo() { 42 }
> }
> @groovy.transform.CompileStatic
> def test() {
> md(
>   new D(), 
>   { print(foo()) }, 
> //  { print(foo()) }, // [Static type checking] - Cannot find matching 
> method ConsoleScript15#foo()
> //  { print(foo()) }, // [Static type checking] - Cannot find matching 
> method ConsoleScript15#foo()
> )
> }
> test()
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GROOVY-8845) @DelegatesTo works only for the first vararg

2018-10-15 Thread Daniil Ovchinnikov (JIRA)


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

Daniil Ovchinnikov commented on GROOVY-8845:


Please close if this is intended.

> @DelegatesTo works only for the first vararg
> 
>
> Key: GROOVY-8845
> URL: https://issues.apache.org/jira/browse/GROOVY-8845
> Project: Groovy
>  Issue Type: Bug
>  Components: Static Type Checker
>Affects Versions: 2.5.3
>Reporter: Daniil Ovchinnikov
>Priority: Major
>
> {code:groovy}
> def md(@DelegatesTo.Target Object target, @DelegatesTo(strategy = 
> Closure.DELEGATE_FIRST) Closure... arg) {
> for (Closure a : arg) {
> a.delegate = target
> a.resolveStrategy = Closure.DELEGATE_FIRST
> a()
> }
> }
> class D {
>   def foo() { 42 }
> }
> @groovy.transform.CompileStatic
> def test() {
> md(
>   new D(), 
>   { print(foo()) }, 
> //  { print(foo()) }, // [Static type checking] - Cannot find matching 
> method ConsoleScript15#foo()
> //  { print(foo()) }, // [Static type checking] - Cannot find matching 
> method ConsoleScript15#foo()
> )
> }
> test()
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)