Suppose I have:
class Blah<T> { void doit(Closure<R> c) }
Used so:
Blah<String> b = new Blah<>("abc")
b.doit {it.trim()}
Is there a ClosureSignatureHint that specifies this?
This method from DGM is what I'd want, except doit is an instance method and
not a static one, so I can't use "FirstParam"
public static <T> Collection<T> each(Collection<T> self,
@ClosureParams(FirstParam.FirstGenericType.class) Closure closure)
I even tried FromString, but type checker still thinks the closure takes object.
void doit(@ClosureParams(value=FromString.class, options=["T"]) Closure<?> c)
[Static type checking] - Cannot find matching method java.lang.Object#trim().
Please check if the declared type is right and if the method exists.
I even tried my own hint class:
public class GenericClassType extends SingleSignatureClosureHint {
public ClassNode[] getParameterTypes(MethodNode node, String[] options,
SourceUnit sourceUnit, CompilationUnit unit, ASTNode usage) {
return new ClassNode[] { pickGenericType(node.getDeclaringClass(), 0) };
}
}
In GenericClassType hint it finds "T -> java.lang.Object". It doesn't seem to
know about the Blah instance.
What's weird is even if I change doit to take a java.util.function.Consumer<T>,
it still doesn't work.
Jason
This email message and any attachments are for the sole use of the intended
recipient(s). Any unauthorized review, use, disclosure or distribution is
prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message and any attachments.