SonarLint Java S2583 False positive: Java 16 pattern matching

Hi,

I’m running SonarLint on IntelliJ (plugin version: 5.1.0.34721, IntelliJ version 2021.2 Ultimate Edition)

Here an example of the issue:

if (o instanceof byte[] arrayByte) {
    doSomethingWithByte(arrayByte);
} else if (o instanceof char[] arrayChar) {
    doSomethingWithChar(arrayChar);
}

The error is reported on second condition if (o instanceof char[] arrayChar) because it is considered as always false.

1 Like

Hello @Lehtto, and welcome to the community!

Indeed, this is a false positive, thanks for taking the time to report it. Ticket created: SONARJAVA-3986.

Have a nice day.
Quentin

1 Like

Hi @Quentin
Thank you for your support and your time.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.