manifold-systems / manifold

Manifold is a Java compiler plugin, its features include Metaprogramming, Properties, Extension Methods, Operator Overloading, Templates, a Preprocessor, and more.
http://manifold.systems/
Apache License 2.0
2.42k stars 125 forks source link

Unable to compile demo project due to tuples utilization #520

Closed ojecborec closed 1 year ago

ojecborec commented 1 year ago

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.

rsmckinney commented 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

ojecborec commented 1 year ago

I got a zip file ready but forgot to send it. Here it is.

demo.zip

rsmckinney commented 1 year ago

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!

rsmckinney commented 1 year ago

fix available with release 2023.1.30

ojecborec commented 1 year ago

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.

rsmckinney commented 1 year ago

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.