Daniil Ovchinnikov created GROOVY-7678:
------------------------------------------

             Summary: @DelegatesTo nested closures owner
                 Key: GROOVY-7678
                 URL: https://issues.apache.org/jira/browse/GROOVY-7678
             Project: Groovy
          Issue Type: Bug
          Components: groovy-runtime
            Reporter: Daniil Ovchinnikov


Consider the following snippet

{code:java}
class X {
    def method() { "X" }

    def anotherMethod(@DelegatesTo(Y) Closure c) { new Y().with(c) }
}

class Y {
    def method() { "Y" }
}

def doX(@DelegatesTo(X) Closure c) { new X().with(c) }

doX {
    anotherMethod {
        println owner.method()      // X (correct)
        println delegate.method()   // Y (correct)
        println method()            // Y (?)
    }
}
{code}

Last {{method()}} call should return {{"X"}} because default strategy is 
{{OWNER_FIRST}} and the owner itself delegates to the {{X}} instance.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to