IDEA-74017 Infer @NotNull/@Nullable annotations for final fields from constructor(s)

This commit is contained in:
peter
2012-06-25 20:30:05 +02:00
parent adf1c737ab
commit e6668c8eaf
4 changed files with 104 additions and 53 deletions
@@ -0,0 +1,21 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class Doo {
private final Object myA;
private final Object myB;
public Doo(@Nullable Object myA, @NotNull Object myB) {
this.myA = myA;
this.myB = myB;
}
int foo() {
if (<warning descr="Condition 'myB != null' is always 'true'">myB != null</warning> &&
<warning descr="Method invocation 'myA.equals(myB)' may produce 'java.lang.NullPointerException'">myA.equals(myB)</warning>) {
return 2;
}
return myA.hashCode();
}
}