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

Daniil Ovchinnikov updated GROOVY-7685:
---------------------------------------
    Description: 
{code:title=nested_closures.groovy}
class X {
    def method() {
        "method $X.name"
    }
}

class MethodCategory {
    static method(a) {
        "method $MethodCategory.name"
    }
}

use(MethodCategory) {
    def c = {
        println "owner ${owner.class.name}"         // owner 
nested_closures$_run_closure1
        println "delegate ${delegate.class.name}"   // delegate X
        println method()                            // !! method MethodCategory
    }
    c.resolveStrategy = Closure.DELEGATE_ONLY
    c.delegate = new X()
    c()
}
{code}

The {{method()}} call inside the {{c}} closure should return {{method X}}.

  was:
{code:title=nested_closures.groovy}
class X {
    def method() {
        "method $X.name"
    }

    def anotherMethod() {
        "another method $X.nclass X 
    }
}

class MethodCategory {
    static def method(a) {
        "method $MethodCategory.name"
    }
}

use(MethodCategory) {
    def c = {
        println "owner ${owner.class.name}"         // owner 
nested_closures$_run_closure1
        println "delegate ${delegate.class.name}"   // delegate X
        println method()                            // !! method MethodCategory
        println anotherMethod()                     // another method X
    }
    c.resolveStrategy = Closure.DELEGATE_ONLY
    c.delegate = new X()
    c()
}
{code}

The {{method()}} call inside the {{c}} closure should return {{method X}}.


> Category overrides closure delegate
> -----------------------------------
>
>                 Key: GROOVY-7685
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7685
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Daniil Ovchinnikov
>
> {code:title=nested_closures.groovy}
> class X {
>     def method() {
>         "method $X.name"
>     }
> }
> class MethodCategory {
>     static method(a) {
>         "method $MethodCategory.name"
>     }
> }
> use(MethodCategory) {
>     def c = {
>         println "owner ${owner.class.name}"         // owner 
> nested_closures$_run_closure1
>         println "delegate ${delegate.class.name}"   // delegate X
>         println method()                            // !! method 
> MethodCategory
>     }
>     c.resolveStrategy = Closure.DELEGATE_ONLY
>     c.delegate = new X()
>     c()
> }
> {code}
> The {{method()}} call inside the {{c}} closure should return {{method X}}.



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

Reply via email to