add cast to disambiguate method calls when replacing their argument with null (IDEA-126466)

This commit is contained in:
peter
2014-07-18 09:14:06 +02:00
parent 65ccc19fbf
commit 1aa6e7ac2b
7 changed files with 62 additions and 12 deletions
@@ -1,13 +1,15 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class Test {
private void test2(@NotNull Object bar) {
private void test2(@NotNull Object bar) {}
void println(@Nullable Object o) {}
}
private Object test(Object foo, Object bar) {
if (foo == null) {
System.out.println(<warning descr="Value 'foo' is always 'null'"><caret>foo</warning>);
System.out.println(<warning descr="Value 'foo' is always 'null'">foo</warning>);
println(<warning descr="Value 'foo' is always 'null'"><caret>foo</warning>);
println(<warning descr="Value 'foo' is always 'null'">foo</warning>);
return <warning descr="Expression 'foo' might evaluate to null but is returned by the method which is not declared as @Nullable">foo</warning>;
}
if (bar == null) {
@@ -0,0 +1,14 @@
import org.jetbrains.annotations.Nullable;
class Test {
void method(@Nullable String o) {}
void method(@Nullable Integer o) {}
private void test(String foo) {
if (foo == null) {
method(<warning descr="Value 'foo' is always 'null'"><caret>foo</warning>);
}
}
}
@@ -0,0 +1,14 @@
import org.jetbrains.annotations.Nullable;
class Test {
void method(@Nullable String o) {}
void method(@Nullable Integer o) {}
private void test(String foo) {
if (foo == null) {
method(<caret>(String) null);
}
}
}
@@ -1,13 +1,15 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class Test {
private void test2(@NotNull Object bar) {
private void test2(@NotNull Object bar) {}
void println(@Nullable Object o) {}
}
private Object test(Object foo, Object bar) {
if (foo == null) {
System.out.println(<caret>null);
System.out.println(foo);
println(<caret>null);
println(foo);
return foo;
}
if (bar == null) {