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 2021/05/27 22:41:00 UTC
[jira] [Closed] (GROOVY-5367) Closure property in Binding used as
Closure delegate cannot be called
[ https://issues.apache.org/jira/browse/GROOVY-5367?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles closed GROOVY-5367.
-------------------------------
Fix Version/s: (was: 4.x)
4.0.0-beta-1
Resolution: Fixed
> Closure property in Binding used as Closure delegate cannot be called
> ---------------------------------------------------------------------
>
> Key: GROOVY-5367
> URL: https://issues.apache.org/jira/browse/GROOVY-5367
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 1.8.6
> Reporter: Wujek
> Priority: Major
> Fix For: 4.0.0-beta-1
>
>
> In a script, this works:
> c = { println 'works' }
> c()
> whereas this one doesn't:
> def bind = new Binding(c: { println 'does not work' })
> def t = { c() }
> t.delegate = bind
> t()
> They both define a 'c' property in the binding which happens to be a closure. In the first case, the closure get's called as Groovy apparently tries to get the binding property and invoke it if it's a closure; in the latter, the delegate of the closure is a binding with a property 'c' that is a closure, but c() still doesn't work.
> I debugged this and there is actually an if in MetaClassImpl that checks if the 'this' object is a Script, and if so, a property with the name is retrieved and a call() method is called. (MetaClassImpl#invokePropertyOrMissing:1089 in Groovy 1.8.6-all from maven central).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)