Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6
-
None
-
Red Hat Linux 5 with groovy 1.6.0 binary distribution; also reproduced on Debian 5.0
Description
From a script, if x is a variable in the binding, calling x() appears not to try calling x's call method, at least in some cases. (It does work for closures, though.) The following example code illustrates the behavior fully. When running the code, it catches the MissingMethodException and print "oops – didn't try c1.call()".
If this is intended behavior, I'd appreciate an explanation. I apologize if this is known. I searched JIRA but didn't find anything. I suspect my indentation will not be preserved here...
class Callable { Object call() { 'Callable.call' } } Callable c = new Callable() assert 'Callable.call' == c() def binding = new Binding() binding.c1 = c binding.c2 = { c() } def shell = new GroovyShell(binding) try { assert 'Callable.call' == shell.evaluate('c1()') } catch (MissingMethodException) { println "oops -- didn't try c1.call()" } assert 'Callable.call' == shell.evaluate('c1.call()') assert 'Callable.call' == shell.evaluate('c2()')
Attachments
Attachments
Issue Links
- relates to
-
GROOVY-8146 Callable properties of closure delegate cannot be called implicitly
- Closed