mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 16:36:56 +07:00
32 lines
878 B
Java
32 lines
878 B
Java
// IDEA-191374
|
|
class B {}
|
|
class A {
|
|
private B b = new B();
|
|
void foo() {
|
|
String s = b != null ? b.toString() : ""; //comment this line and the error will appear
|
|
|
|
if (<warning descr="Condition 'b instanceof B' is redundant and can be replaced with a null check">b instanceof B</warning>) { // no error reported here
|
|
System.out.println(b);
|
|
}
|
|
}
|
|
|
|
interface Base {
|
|
void doSmth();
|
|
}
|
|
interface Sub extends Base {}
|
|
|
|
private static void test(Base[] operands) {
|
|
operands[0].doSmth();
|
|
if (operands[0] instanceof Sub) {
|
|
System.out.println("possible");
|
|
}
|
|
}
|
|
|
|
private static void test2(Sub[] operands) {
|
|
operands[0].doSmth();
|
|
if (<warning descr="Condition 'operands[0] instanceof Base' is redundant and can be replaced with a null check">operands[0] instanceof Base</warning>) {
|
|
System.out.println("always");
|
|
}
|
|
}
|
|
|
|
} |