groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Milles (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (GROOVY-8375) Closure resolve strategy DELEGATE_FIRST and DELEGATE_ONLY behave oddly when delegate is set
Date Thu, 09 Nov 2017 16:47:00 GMT

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

Eric Milles updated GROOVY-8375:
--------------------------------
    Description: 
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.

  was:
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.


> 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 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
(v6.4.14#64029)

Mime
View raw message