mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
dfa: a variable can't be null after dereference (IDEA-122215)
This commit is contained in:
+21
@@ -18,6 +18,27 @@ class Bar3 {
|
||||
if (first == getObj() || collection.size() > 0) {
|
||||
System.out.println(first.hashCode());
|
||||
}
|
||||
if (<warning descr="Condition 'first == null' is always 'false'">first == null</warning>) {
|
||||
System.out.println(first.hashCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void foo2(Collection<Object> collection) {
|
||||
if (!collection.isEmpty()) {
|
||||
Object first = collection.iterator().next();
|
||||
if (first != getObj() || collection.size() > 0) {
|
||||
first.hashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void foo3(Collection<Object> collection) {
|
||||
if (!collection.isEmpty()) {
|
||||
Object first = collection.iterator().next();
|
||||
if (first == getObj() || collection.size() > 2) {
|
||||
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>);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class Foo {
|
||||
|
||||
private void someMethod(String someArg) {
|
||||
someArg.getClass();
|
||||
if (<warning descr="Condition 'someArg == null' is always 'false'">someArg == null</warning>) {
|
||||
System.err.println("Wrong argument");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user