Skip to content

[java] False positive for UseInstanceofToCompareClasses on local generic class #30

@oowekyala

Description

@oowekyala

UseInstanceofToCompareClasses reports on non-reifiable types, even though they're not acceptable as operand to instanceof. E.g.:

class Foo<T> {

public Foo<T> wrap() {
   // since the local class is not static, the T here refers to the T of the outer instance
   class MyWrapper extends Foo<T> {
      
   }
   this instanceof MyWrapper // -> error, MyWrapper is not reifiable, because its supertype Foo<T> isn't 

   this.getClass().equals(MyWrapper.class) // this is the only way to compare it
} 

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions