Hi,
I'm struggling with something I believe should be possible - when a
Closure is parsed at runtime, it should be possible to retrieve its
generic return type.
I have the following (in Java):
@Test
public void testClosureReturnTypeExtraction() {
String script = "def a = { 1L }";
Closure<?> closure = (Closure<?>) compile(script).run();
Class<?> returnType = retrieveReturnTypeFrom(closure); //
how to implement this??
assertEquals(Long.class, returnType);
}
What I cannot figure out is how to extract the type information from the
generated closure. I believe the type information should be there (or at
least it should be possible to put it there). So far, my best attempt
was, that I got that the type argument is "V". :-)
Any pointers would be appreciated.
Cheers,
Jan