You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (JIRA)" <ji...@apache.org> on 2017/11/09 15:56:00 UTC
[jira] [Created] (GROOVY-8375) Closure resolve strategy
DELEGATE_FIRST and DELEGATE_ONLY behave oddly when delegate is set
Eric Milles created GROOVY-8375:
-----------------------------------
Summary: Closure resolve strategy DELEGATE_FIRST and DELEGATE_ONLY behave oddly when delegate is set
Key: GROOVY-8375
URL: https://issues.apache.org/jira/browse/GROOVY-8375
Project: Groovy
Issue Type: Bug
Reporter: Eric Milles
The sample below outputs "value" as is. When {cl.resolveStrategy = Closure.DELEGATE_FIRST} is added before {cl()}, it outputs {null} when I would expect {value} since that's available from owner. When {cl.resolveStrategy = Closure.DELEGATE_ONLY} is added instead, it outputs {null} when I would expect missing property exception.
{code}
class Test {
def prop = 'value'
def meth() {
def cl = { -> println prop }
cl.delegate = [:]
cl()
}
}
new Test().meth()
{code}
This was run using Groovy Web Console.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)