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

Jochen Theodorou closed GROOVY-8375.
------------------------------------
    Resolution: Won't Fix
      Assignee: Jochen Theodorou

even if the map has no values in it,it still answers what the value for prop is 
when we ask it. Since it gives us an answer and does not fail, we take that 
answer. If the delegate is successfully asked, there is no reason for 
DELEGATE_FIRST and DELEGATE_ONLY to asked the owner (Test) as well.

> 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
>            Assignee: Jochen Theodorou
>            Priority: Major
>
> 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 a 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
(v7.6.3#76005)

Reply via email to