[ https://issues.apache.org/jira/browse/GROOVY-6651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King closed GROOVY-6651. ----------------------------- > Calling a closure declared as a field from within another closure > ----------------------------------------------------------------- > > Key: GROOVY-6651 > URL: https://issues.apache.org/jira/browse/GROOVY-6651 > Project: Groovy > Issue Type: Bug > Components: groovy-runtime > Affects Versions: 1.8.9, 2.1.9, 2.4.0-beta-3 > Reporter: Andreas Lang > Priority: Minor > > The following test demonstrates the problem: > {code} > class MemoizedClosureTests { > static class Pogo { > def myMemoizedClosure = { String lalala -> }.memoize() > void doSomething() { > 1.times { > myMemoizedClosure('hello') > } > } > } > @Test > void testMemoizedFieldFromWithinClosure() { > new Pogo().doSomething() > } > } > {code} > This causes the following exception: > {code} > groovy.lang.MissingMethodException: No signature of method: > org.codehaus.groovy.runtime.memoize.Memoize$MemoizeFunction.doCall() is > applicable for argument types: (java.lang.String) values: [hello] > Possible solutions: call(), call([Ljava.lang.Object;), > call(java.lang.Object), call([Ljava.lang.Object;), findAll(), > equals(java.lang.Object) > at > cern.ais.plugin.MemoizedClosureTest$_Pogo_doSomething_closure2.doCall(MemoizedClosureTest.groovy:13) > at > cern.ais.plugin.MemoizedClosureTest$Pogo.doSomething(MemoizedClosureTest.groovy:12) > at > cern.ais.plugin.MemoizedClosureTest.testMemoizeFieldFromWithinClosure(MemoizedClosureTest.groovy:20) > {code} > Interestingly it works fine in the following cases: > * Calling myMemoizedClosure just in the method not within the closure > * Decalring myMemoizedClosure as a local variable > * Having a non-memoized closure instead > * Using {code}myMemoizedClosure.call('hello') {code} (my workaround) > I tested it in two groovy versions I had around 1.8.9 and 2.1.9 -- This message was sent by Atlassian Jira (v8.20.10#820010)