eclipse-tycho / tycho

Tycho project repository (tycho)
https://tycho.eclipseprojects.io
Eclipse Public License 2.0
171 stars 193 forks source link

Non-empty lambda considered empty by tycho-compiler-plugin:2.7.3 #3075

Open mlntdrv opened 1 year ago

mlntdrv commented 1 year ago

[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:2.7.3:compile (default-compile) on project com.myproject: Compilation failure: Compilation failure: [ERROR] /builds/MyClass.java:[67] [ERROR] final List somethings = first.or(() -> second) [ERROR] ^^ [ERROR] The method or(() -> {}) is undefined for the type Optional<List> [ERROR] 1 problem (1 error)

Code:

        final Optional<List<Something>> first = Optional.ofNullable(null);
        final Optional<List<Something>> second = Optional.ofNullable(null);
        final List<Something> somethings = first.or(() -> second)
                .orElse(new ArrayList<>(Arrays.asList(Something.withArgs(0, 0))));

There is a Supplier that's been fed to Optional#or, which returns another Optional, so definitely not an empty lambda, but Supplier<Optional<List<Something>>> instead.

akurtakov commented 1 year ago

Tycho 2.7.3 is ancient version (uses ecj 3.25.0) . As compilation is actually done by ECJ you should update to recent Tycho (4.0.4) in order to check whether the issue is fixed in newer ecj version. You may also want to try whether the code in question compiles in latest Eclipse version which would mean that ECJ is fixed.

mlntdrv commented 1 year ago

v2.7.3 is from a year and a half ago, is it already out of support?

akurtakov commented 1 year ago

Only latest major stream is supported aka 4.x now. When 5.0.0 is out , 5.x would be the supported stream.

laeubi commented 1 year ago

v2.7.3 is from a year and a half ago, is it already out of support?

Means 6 new releases of Eclipse compiler, nevertheless it should work to specify a never ECJ even with Tycho 2.7.3 (please be aware that there is even a 2.7.5 out), but as @akurtakov mentions it is very unlikely that if there is a problem we can analyze and fix it see https://github.com/eclipse-tycho/tycho/blob/master/CONTRIBUTING.md#backporting especially if it is a compiler bug.

mlntdrv commented 1 year ago

Thank you for your responses, guys.

it should work to specify a never ECJ even with Tycho 2.7.3 (please be aware that there is even a 2.7.5 out)

I've tried with 2.7.5, same (both 2.7.3 and 2.7.5 use ecj-3.29.0 BTW). How can I change the ECJ version for tycho-2.7.5? I use the following plugins: tycho-maven-plugin target-platform-configuration tycho-p2-repository-plugin tycho-p2-director-plugin