Skip to content

Add Check Support for Java 21 Unnamed Variables & Patterns Syntax: HiddenField #15066

@mahfouz72

Description

@mahfouz72

child of #14942

Check documentation : https://checkstyle.org/checks/coding/hiddenfield.html


unnamed variables can't be fields so the hidden field check won't get affected by unnamed variables.

public class Test {
    String c;
    void test(Object obj) {
        if (obj instanceof ColoredPoint(String c, String _, int _)) {  // violation, c hides field 
                                                //  '_' can't hide a field
            c.equals("s");
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions