eclipse-jdt/eclipse.jdt.core

"Ignore in overriding and implementing method" not working for method references

Open

#3.944 geöffnet am 20. Apr. 2025

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (0 zugewiesene Personen)Java (183 Forks)auto 404
good first issuehelp wanted

Repository-Metriken

Stars
 (233 Stars)
PR-Merge-Metriken
 (PR-Metriken ausstehend)

Beschreibung

Version: 2025-03 (4.35.0) Build id: 20250306-0812 JDK: jdk-21.0.6+7

When "Ignore in overriding and implementing method" is checked, unused parameters are ignored if the method is overriding or implementing an abstract method. If the method is implementing a functional interface as a method reference, eclipse shows the warning for any unused parameters.

In this example the parameter someParam is marked as unused, even though the method methodImplementation is used for implementating a functional interface.

public class Showcase {

    @FunctionalInterface
    interface MyFunction {
        int apply(int someParam, int someOtherParam);
    }

    public static void main(String[] args) {
        test(Showcase::methodImplementation);
    }

    private static void test(MyFunction func) {
        var result = func.apply(42, 9001);
        System.out.println("Result: " + result);
    }

    // someParam marked as unused, even if "Ignore in overriding and implementing method" is checked
    private static int methodImplementation(int someParam, int someOtherParam) {
        return someOtherParam;
    }

}

Contributor Guide