DFA: support partial streams and ::isInstance method reference

Fixes:
IDEA-182519 Support non-terminated Stream API chains in data flow
IDEA-182520 Support Xyz.class::isInstance in stream/optional chains
This commit is contained in:
Tagir Valeev
2017-11-22 14:23:00 +07:00
parent 7c9f5ce2c9
commit 80e63e20fc
14 changed files with 185 additions and 14 deletions
@@ -0,0 +1,9 @@
// "Replace with a null check" "true"
class Test {
void test(String s) {
Object obj = s;
if(obj != null) {
System.out.println("always");
}
}
}
@@ -0,0 +1,10 @@
// "Replace with a null check" "true"
import java.util.Objects;
import java.util.stream.Stream;
class Test {
void test(Stream<String> s) {
s.filter(Objects::nonNull)
.forEach(System.out::println);
}
}
@@ -0,0 +1,9 @@
// "Replace with a null check" "true"
class Test {
void test(String s) {
Object obj = s;
if(obj instanceof <caret>String) {
System.out.println("always");
}
}
}
@@ -0,0 +1,9 @@
// "Replace with a null check" "true"
import java.util.stream.Stream;
class Test {
void test(Stream<String> s) {
s.filter(String.class::<caret>isInstance)
.forEach(System.out::println);
}
}