Inspectopedia Help

Lambda-unfriendly method overload

Reports overloaded methods that take functional interfaces with conflicting abstract method signatures.

Such overloads introduce ambiguity and require callers to cast lambdas to a specific type or specify lambda parameter types explicitly. It is preferable to give the overloaded methods different names to eliminate ambiguity.


interface MyExecutor { void execute(Supplier<?> supplier); void execute(Callable<?> callable); }

Here, Supplier and Callable are functional interfaces whose single abstract methods do not take any parameters and return a non-void value. As a result, the type of the lambda cannot be inferred at the call site unless an explicit cast is used.

Inspection Details

Available in:

IntelliJ IDEA 2023.3, Qodana for JVM 2023.3


Java, 233.SNAPSHOT

Last modified: 13 July 2023