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

Daniel Sun commented on GROOVY-8845:
------------------------------------

Fixed on master; added a regression test in 
844951e533e0fcd861226fdffa7fe7640bd5476b 
(https://github.com/apache/groovy/commit/844951e533e0fcd861226fdffa7fe7640bd5476b).

> @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
>            Assignee: Daniel Sun
>            Priority: Major
>              Labels: varargs
>             Fix For: 7.0.0-alpha-1
>
>
> {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
(v10.3.26#10030026)

Reply via email to