You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "James Kleeh (JIRA)" <ji...@apache.org> on 2016/07/29 15:19:20 UTC

[jira] [Created] (GROOVY-7895) ExpandoMetaClass behaves differently from ClosureMetaClass

James Kleeh created GROOVY-7895:
-----------------------------------

             Summary: ExpandoMetaClass behaves differently from ClosureMetaClass
                 Key: GROOVY-7895
                 URL: https://issues.apache.org/jira/browse/GROOVY-7895
             Project: Groovy
          Issue Type: Bug
          Components: groovy-runtime
    Affects Versions: 2.4.7
            Reporter: James Kleeh


The following demonstrates this issue:

{code}
ExpandoMetaClass.disableGlobally()

class Foo {
    String name
    void bar() {
        println name
    }
}

Closure parent = {
    Closure child = {
        bar()
    }
    child.delegate = new Foo(name: "delegate")
    child.call()
}

parent.delegate = new Foo(name: "ownerDelegate")
parent.resolveStrategy = Closure.DELEGATE_FIRST
parent.call()

ExpandoMetaClass.enableGlobally()

parent = {
    Closure child = {
        bar()
    }
    child.delegate = new Foo(name: "delegate")
    child.call()
}

parent.delegate = new Foo(name: "ownerDelegate")
parent.resolveStrategy = Closure.DELEGATE_FIRST
parent.call()

ExpandoMetaClass.disableGlobally()
{code}

ExpandoMetaClass calls the method on the delegate even though the method exists on the owner via the owner's delegate.



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