Inner class field hides outer class field
Reports inner class fields named identically to a field of a surrounding class. As a result of such naming, you may accidentally use the field from the inner class when using the identically named field of a surrounding class is intended.
A quick-fix is suggested to rename the inner class field.
Example:
class Outer {
private String name;
class Inner {
private String name;
}
}
Use the option to choose whether this inspection should report all name clashes, or only clashes with fields that are visible from the inner class.
Inspection options
Option | Type | Default |
---|---|---|
Ignore outer fields not visible from inner class | Checkbox | true |
Inspection Details | |
---|---|
Available in: | IntelliJ IDEA 2023.3, Qodana for JVM 2023.3 |
Plugin: | Java, 233.SNAPSHOT |
Last modified: 13 July 2023