In general, when STC is processing Type::name to match against Function interface it looks for 1-parameter static method of Type or 0-parameter instance method of Type — the instance is the implied parameter. It should also look for 1-parameter instance method of Class. I don't know how many test cases we have for the third thing. But there are quite a few for the static and instance variants in https://github.com/apache/groovy/blob/master/src/test/groovy/groovy/transform/stc/MethodReferenceTest.groovy
Please do raise a new bug item for the "Type::cast" STC error. ________________________________ From: Christopher Smith <chrylis+gro...@gmail.com> Sent: Tuesday, April 29, 2025 1:46 PM To: dev@groovy.apache.org <dev@groovy.apache.org> Subject: [EXT] Method reference for Class::cast? External Email: Use caution with links and attachments. I have a functional pipeline calling a method whose signature returns a base class of a specific class I know will be used at runtime. In Java, I can write something like this: .map(ConcreteClass.class::cast) However, I can't figure out how (or if?) I can do this in Groovy (static compilation). My initial approach of `(ConcreteClass::cast)` causes the compiler to complain that there's no instance method `cast` on ConcreteClass, and I am not sure if there's a syntax to unambiguously communicate that "I want you to call `cast` on this specific class object, not look for a method named `cast` declared on this type".