Closed ojecborec closed 1 year ago
Can you provide some context for the .map expression? I’ll be able to diagnose the problem quicker if I have access to your demo. Thanks
Thanks. I've diagnosed the problem. Generally, a method with an auto
return type that resolves to an anonymous type, such as a tuple type, cannot be used as a method reference. As you've discovered, you must instead use a lambda.
I'm addressing this issue by adding a compiler message indicating that lambda usage is required here. This change will be available in the next manifold release later in the week. Thanks for reporting this!
fix available with release 2023.1.30
Hi. Is there really no way how to make it work with method reference? Method references are used a lot and it would be nice to support it.
It’s not impossible. I plan to circle back on this because there are other features such as extension methods that don’t work with method refs. The solution is similar.
Running
mvn clean package
I'm getting
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project service: Compilation failure: Compilation failure: [ERROR] demo/service/src/main/java/com/example/demo/service/DemoApplication.java:[21,49] cannot find symbol [ERROR] symbol: variable name [ERROR] location: variable t of type java.lang.Object [ERROR] demo/service/src/main/java/com/example/demo/service/DemoApplication.java:[21,57] cannot find symbol [ERROR] symbol: variable age [ERROR] location: variable t of type java.lang.Object [ERROR] demo/service/src/main/java/com/example/demo/service/DemoApplication.java:[22,40] incompatible types: java.util.List cannot be converted to java.util.Collection
However when I replace
.map(this::subject)
with
.map(n -> subject(n))
project compiles just fine.