IDEA-187645 NPE warning is not issued when "null -> null" method is called with Nullable argument

This commit is contained in:
Tagir Valeev
2018-03-03 15:02:58 +07:00
parent 5ce39944b6
commit 48848a8a7b
2 changed files with 32 additions and 3 deletions
@@ -2,6 +2,26 @@ import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class Test2 {
interface Project {}
interface Sdk {}
interface Version {}
@NotNull
native static Test2 getInstance(Project project);
@Nullable
native Sdk getProjectSdk();
@Contract("null -> null")
native static Version getVersion(@Nullable Sdk sdk);
static void test(Project project) {
Version version = getVersion(getInstance(project).getProjectSdk());
System.out.println(version.<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
}
}
class Foo {
public void main(@NotNull Object nn) {
@@ -58,4 +78,4 @@ class Test {
String test() {
return convert(getName());
}
}
}