IDEA-85035 Wrong "possible NPE" warning

This commit is contained in:
peter
2012-04-23 15:58:21 +02:00
parent 9c2e2c691e
commit f0d7a0d5a6
3 changed files with 27 additions and 10 deletions
@@ -0,0 +1,26 @@
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
public 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>);
}
}
}
}