Back to Intellij Community

LambdaParameterHidingMemberVariable

java/java-impl/resources/inspectionDescriptions/LambdaParameterHidingMemberVariable.html

2025.3-rc-2565 B
Original Source

Reports lambda parameters named identically to a field of a surrounding class. As a result of such naming, you may accidentally use the lambda parameter when using the identically named field is intended.

A quick-fix is suggested to rename the lambda parameter.

Example:

public class MyClass {
    public Object foo;

    void sort(List<Integer> list) {
      list.sort((foo, bar) -> foo - bar);
    }
  }

Use the option to choose whether to ignore fields that are not visible from the lambda expression. For example, private fields of a superclass.