summaryrefslogtreecommitdiff
path: root/java/java-tests/testData/inspection/dataFlow/fixture/ComparingToNotNullShouldNotAffectNullity.java
blob: fed3d1b79015a2cb97ce29a86d0c53c34df1044c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import org.jetbrains.annotations.NotNull;

import java.util.Collection;

class Bar3 {

  @NotNull
  Object getObj() {
    return new Object();
  }

  void foo(Collection<Object> collection) {
    if (!collection.isEmpty()) {
      Object first = collection.iterator().next();
      if (first != getObj() || collection.size() > 0) {
        System.out.println(first.hashCode());
      }
      if (first == getObj() || collection.size() > 0) {
        System.out.println(first.hashCode());
      }
      if (first == null) {
        System.out.println(<warning descr="Method invocation 'first.hashCode()' may produce 'java.lang.NullPointerException'">first.hashCode()</warning>);
      }
    }
  }
}