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.
Example:
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.
Locating this inspection
- By ID
Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.
LambdaUnfriendlyMethodOverload- Via Settings dialog
Path to the inspection settings via IntelliJ Platform IDE Settings dialog, when you need to adjust inspection settings directly from your IDE.
Suppressing Inspection
You can suppress this inspection by placing the following comment marker before the code fragment where you no longer want messages from this inspection to appear:
More detailed instructions as well as other ways and options that you have can be found in the product documentation:
Inspection Details | |
|---|---|
By default bundled with: |