IDEA-209947 Report obviously not-null values; better propagation through assignment

GitOrigin-RevId: 2f6cd06b9750e8f080ab543af40b522f4c2bfefa
This commit is contained in:
Tagir Valeev
2019-04-28 16:47:05 +03:00
committed by intellij-monorepo-bot
parent efcbb20422
commit e12a1970e4
7 changed files with 95 additions and 33 deletions
@@ -0,0 +1,19 @@
/*
Value is always true (j >= 0)
Left operand is >= 0 (j)
'j' was assigned (i + 1)
Result of '+' is >= 0 (i + 1)
Left operand is in {-1..Integer.MAX_VALUE-1} (i)
'i' was assigned (s.indexOf(' '))
Value is in {-1..Integer.MAX_VALUE-1} (s.indexOf(' '))
*/
class Test {
private static void dosmth(String s) {
int i = s.indexOf(' ');
int j = i + 1;
if (<selection>j >= 0</selection>) {
}
}
}
@@ -0,0 +1,12 @@
/*
Value is always true ((s = new Object()) != null)
's' was assigned (new Object())
Expression cannot be null as it's newly created object (new Object())
*/
class Test {
void test() {
Object s;
if (<selection>(s = new Object()) != null</selection>) {}
}
}
@@ -0,0 +1,12 @@
/*
Value is always true (s != null)
's' was assigned (new Object())
Expression cannot be null as it's newly created object (new Object())
*/
class Test {
void test() {
Object s = (new Object());
if (<selection>s != null</selection>) {}
}
}