SuspiciousTernaryOperatorInVarargsCallInspection created: IDEA-244144

GitOrigin-RevId: cc56e98bf46b87d1b685177a72bccfd4fc80a596
This commit is contained in:
Andrey.Cherkasov
2020-09-18 23:04:15 +00:00
committed by intellij-monorepo-bot
parent 11c6134b4a
commit eb5e81dcb4
9 changed files with 205 additions and 0 deletions
@@ -0,0 +1,16 @@
// "Replace with 'new Object[]{b}'" "true"
class Test {
public static void main(String[] args) {
Object[] a = {1, 2};
Object b = "hello";
foo(0, a);
foo(0, b);
for (boolean flag : new boolean[]{true, false}) {
foo(0, flag ? a : new Object[]{b});
foo(0, 1, flag ? a : b);
}
}
static void foo(int x, Object... xs) {
}
}
@@ -0,0 +1,18 @@
// "Replace with 'new Serializable[]{b}'" "true"
import java.io.Serializable;
class Test {
public static void main(String[] args) {
Serializable[] a = {1, 2};
Serializable b = "hello";
foo(0, a);
foo(0, b);
for (boolean flag : new boolean[]{true, false}) {
foo(0, flag ? a : new Serializable[]{b});
foo(0, 1, flag ? a : b);
}
}
static void foo(int x, Serializable... xs) {
}
}
@@ -0,0 +1,16 @@
// "Replace with 'new Object[]{b}'" "true"
class Test {
public static void main(String[] args) {
Object[] a = {1, 2};
Object b = "hello";
foo(0, a);
foo(0, b);
for (boolean flag : new boolean[]{true, false}) {
foo(0, flag ? a : b<caret>);
foo(0, 1, flag ? a : b);
}
}
static void foo(int x, Object... xs) {
}
}
@@ -0,0 +1,18 @@
// "Replace with 'new Serializable[]{b}'" "true"
import java.io.Serializable;
class Test {
public static void main(String[] args) {
Serializable[] a = {1, 2};
Serializable b = "hello";
foo(0, a);
foo(0, b);
for (boolean flag : new boolean[]{true, false}) {
foo(0, flag ? a : b<caret>);
foo(0, 1, flag ? a : b);
}
}
static void foo(int x, Serializable... xs) {
}
}