summaryrefslogtreecommitdiff
path: root/java/java-tests/testData/inspection/dataFlow/fixture/ComparingNullableToUnknown.java
blob: b15c6c7a52f739d9d205963cc1d8f86ecc2b34e7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;

class Bar3 {

  public void foo(@Nullable Object element) {
    final String elementType = element != null ? element.toString() : null;
    if (elementType == someString()) {
      System.out.println(<warning descr="Method invocation 'element.hashCode()' may produce 'java.lang.NullPointerException'">element.hashCode()</warning>);
    }
  }

  String someString() { return <warning descr="'null' is returned by the method which is not declared as @Nullable">null</warning>; }
}