Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.6.7
-
None
-
Groovy Shell (1.6.7, JVM: 1.5.0_20)
Description
Expando.metaClass.foo={-> def directBar=delegate.bar() println "directBar=${directBar}" def invokedBar=delegate.invokeMethod('bar',null) println "invokedBar=$invokedBar" } e=new Expando() e.metaClass.bar={->1} e.foo() //directBar=1 //invokedBar=1 e.metaClass.bar={->2} e.foo() //directBar=1 //invokedBar=2
for some reason delegate.bar() != delegate.invokeMethod('bar',null)
looks like at the direct call the closure got cached ...
if the previous example continues with:
x=new Expando() x.metaClass.bar={->3} e.foo() //directBar=2 //invokedBar=2
creating the new 'x' object has side effect on the 'e' objects metaclass?