Add IDEA data-flow analysis to guess nullability

Add "if return..." folding to "return if"
This commit is contained in:
Simon Ogorodnik
2017-05-25 15:54:10 +03:00
parent 1f26353de4
commit e41c027c9a
24 changed files with 261 additions and 40 deletions
@@ -0,0 +1,26 @@
public class SomeService {
public static SomeService getInstanceNotNull() {
return new SomeService();
}
public static SomeService getInstanceNullable() {
if (Math.random() > 0.5)
return null;
return new SomeService();
}
public String nullableString() {
if (Math.random() < 0.5)
return null;
return Math.random() + "";
}
public String notNullString() {
String s = nullableString();
if (s != null)
return s;
return "null";
}
}