mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
add cast to disambiguate method calls when replacing their argument with null (IDEA-126466)
This commit is contained in:
@@ -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) {
|
||||
|
||||
+14
@@ -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>);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+6
-4
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user