groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniil Ovchinnikov (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-8845) @DelegatesTo works only for the first vararg
Date Mon, 15 Oct 2018 14:29:00 GMT
Daniil Ovchinnikov created GROOVY-8845:
------------------------------------------

             Summary: @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


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

Mime
View raw message