equals implies not-nullness of its argument (IDEA-88777, IDEA-92809, IDEA-16979)

This commit is contained in:
peter
2012-10-29 12:57:23 +01:00
parent 733b09331a
commit 8114b9af49
7 changed files with 62 additions and 7 deletions
@@ -0,0 +1,24 @@
import org.jetbrains.annotations.NotNull;
class Test {
public static void main(String[] args) {
Object first = null;
for (int i = 0; i < 10; i++) {
if (!"b".equals(first)) {
first = "b";
}
System.out.println(first.toString());
}
}
public void buggyInspectionExample(Object parentNode) {
final String parentName = parentNode == null ? null : parentNode.toString();
if ("Topics".equals(parentName)) {
System.out.println(parentNode.toString());
} else if ("Queues".equals(parentName)) {
System.out.println(parentNode.toString());
}
System.out.println(<warning descr="Method invocation 'parentNode.toString()' may produce 'java.lang.NullPointerException'">parentNode.toString()</warning>);
}
}