Inspectopedia Help

Pattern variable hides field

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

A quick-fix is suggested to rename the variable.


class Pointless { Point p = new Point(); public void test(Object a) { if (a instanceof Point p) { System.out.print("a is a point (" + p.x + ", " + p.y + ')'); } else { System.out.print("p is a point (" + p.x + ", " + p.y + ')'); } } }

Locating this inspection


Can be used to locate inspection in e.g. Qodana configuration files, where you can quickly enable or disable it, or adjust its settings.

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.

Settings or Preferences | Editor | Inspections | Java | Visibility

New in 2022.2


By default bundled with

IntelliJ IDEA 2024.1, Qodana for JVM 2024.1,

Can be installed with plugin

Java, 241.18072

Last modified: 18 June 2024