IterableUsedAsVararg: fixes according to review IDEA-CR-45949

This commit is contained in:
Tagir Valeev
2019-04-10 14:49:18 +07:00
parent 4e4c6ed950
commit cb2e86701d
4 changed files with 67 additions and 9 deletions
@@ -0,0 +1,26 @@
// "Call 'toArray(new String[0])'" "true"
import java.util.List;
import java.util.Objects;
class Test {
static <T> boolean contains(T needle, T... haystack) {
for (final T t : haystack) {
if (Objects.equals(t, needle)) {
return true;
}
}
return false;
}
static <T> boolean contains(String needle, String... haystack) {
return contains((Object)needle, (Object[])haystack);
}
void use(String s) {
if (contains(s, getList().toArray(new String[0]))) {
}
}
native List<String> getList();
}
@@ -0,0 +1,26 @@
// "Call 'toArray(new String[0])'" "true"
import java.util.List;
import java.util.Objects;
class Test {
static <T> boolean contains(T needle, T... haystack) {
for (final T t : haystack) {
if (Objects.equals(t, needle)) {
return true;
}
}
return false;
}
static <T> boolean contains(String needle, String... haystack) {
return contains((Object)needle, (Object[])haystack);
}
void use(String s) {
if (contains(s, <caret>getList())) {
}
}
native List<String> getList();
}