mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
suspicious method calls: don't ignore array types, captures, etc (IDEA-153097)
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class Main {
|
||||
void suspicious(Object[][] data) {
|
||||
List<String> stringList = new ArrayList<>();
|
||||
|
||||
stringList.remove(<warning descr="'List<String>' may not contain objects of type 'Object[][]'">data</warning>);
|
||||
stringList.remove(<warning descr="'List<String>' may not contain objects of type 'Object[]'">data[0]</warning>);
|
||||
stringList.remove(<warning descr="Suspicious call to 'List.remove'">data[0][0]</warning>);
|
||||
|
||||
stringList.contains(<warning descr="'List<String>' may not contain objects of type 'Object[][]'">data</warning>);
|
||||
stringList.contains(<warning descr="'List<String>' may not contain objects of type 'Object[]'">data[0]</warning>);
|
||||
stringList.contains(<warning descr="Suspicious call to 'List.contains'">data[0][0]</warning>);
|
||||
|
||||
M<? extends String> m = new M<>();
|
||||
stringList.contains(m.get());
|
||||
|
||||
M<? super String> m1 = new M<>();
|
||||
stringList.contains(<warning descr="Suspicious call to 'List.contains'">m1.get()</warning>);
|
||||
|
||||
M<?> m2 = new M<>();
|
||||
stringList.contains(<warning descr="Suspicious call to 'List.contains'">m2.get()</warning>);
|
||||
}
|
||||
|
||||
class M<T> {
|
||||
public T get() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
@@ -29,6 +29,10 @@ public class SuspiciousCollectionMethodCallsTest extends LightCodeInsightFixture
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testNonClassArgTypes() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
|
||||
Reference in New Issue
Block a user