SuspiciousArrayMethodCallInspection: erased types are compared (fixes IDEA-172742). As the corresponding argument accepts Object or Object[], exact generic signature cannot be always inferred.

This commit is contained in:
Tagir Valeev
2017-05-12 11:11:05 +07:00
parent d83bfc0b76
commit ed2d5b33fe
3 changed files with 29 additions and 1 deletions
@@ -1,4 +1,4 @@
import java.util.Arrays;
import java.util.*;
public class SuspiciousArrayMethodCall {
void test() {
@@ -27,4 +27,20 @@ public class SuspiciousArrayMethodCall {
return Arrays.<warning descr="Array types are incompatible: arrays are always different">equals</warning>(arr, arr2) ||
Arrays.<warning descr="Array types are incompatible: arrays are always different">equals</warning>(arr2, arr);
}
static class TestOptional {
private Optional<Boolean>[] optionals =
(Optional<Boolean>[])new Optional[2];
public TestOptional() {
Arrays.fill(optionals, Optional.empty()); //IDEA-172742
}
public static void main(String[] args) {
TestOptional t = new TestOptional();
System.out.println(t.optionals[0].isPresent());
System.out.println(t.optionals[1].isPresent());
}
}
}