Support parentheses, fix bug when the array branch has a primitive array, more tests: IDEA-244144

GitOrigin-RevId: 4c644d8b1e11869e4f3853763d09d7e0b91b5740
This commit is contained in:
Andrey.Cherkasov
2020-09-22 12:24:19 +00:00
committed by intellij-monorepo-bot
parent 25c8da92e3
commit 9845c0a0c2
13 changed files with 112 additions and 32 deletions
@@ -0,0 +1,12 @@
// "Replace with 'new Object[]{a}'" "false"
// "Replace with 'new Object[]{b}'" "false"
class Test {
static void bar(boolean flag) {
Object[] a = {1, 2};
Object b = "hello";
foo(0, 1, flag ? a : b);
}
static void foo(int x, Object... xs) {
}
}
@@ -1,15 +1,10 @@
// "Replace with 'new Object[]{b}'" "true"
class Test {
public static void main(String[] args) {
static void bar(boolean flag) {
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);
}
foo(0, flag ? a : new Object[]{b});
}
static void foo(int x, Object... xs) {
}
@@ -0,0 +1,11 @@
// "Replace with 'new Object[]{b}'" "false"
class Test {
static void bar(boolean flag) {
int[] a = {1, 2};
Integer b = 42;
foo(0, flag ? a : b);
}
static void foo(int x, Object... xs) {
}
}
@@ -3,15 +3,10 @@
import java.io.Serializable;
class Test {
public static void main(String[] args) {
static void bar(boolean flag) {
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);
}
foo(0, flag ? a : new Serializable[]{b});
}
static void foo(int x, Serializable... xs) {
}
@@ -0,0 +1,11 @@
// "Replace with 'new Object[]{getObject(/*empty*/)}'" "true"
class Test {
static void foo(Object... data) { }
void test(boolean b, Object[] obj2) {
foo(b ? new Object[]{getObject(/*empty*/)} : obj2);
}
native Object getObject();
}
@@ -0,0 +1,15 @@
// "Replace with 'new Object[]{b}'" "true"
class Test {
static void bar(boolean flag) {
Integer[] a = {1, 2};
Integer b = 42;
foo(0, (((flag ? a : new Object[]{b}))));
}
static void foo(int x, Object... xs) {
}
public static void main(String[] args) {
bar(true);
}
}
@@ -0,0 +1,12 @@
// "Replace with 'new Object[]{a}'" "false"
// "Replace with 'new Object[]{b}'" "false"
class Test {
static void bar(boolean flag) {
Object[] a = {1, 2};
Object b = "hello";
foo(0, 1, flag ? a : b<caret>);
}
static void foo(int x, Object... xs) {
}
}
@@ -1,15 +1,10 @@
// "Replace with 'new Object[]{b}'" "true"
class Test {
public static void main(String[] args) {
static void bar(boolean flag) {
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);
}
foo(0, flag ? a : b<caret>);
}
static void foo(int x, Object... xs) {
}
@@ -0,0 +1,11 @@
// "Replace with 'new Object[]{b}'" "false"
class Test {
static void bar(boolean flag) {
int[] a = {1, 2};
Integer b = 42;
foo(0, flag ? a : b<caret>);
}
static void foo(int x, Object... xs) {
}
}
@@ -3,15 +3,10 @@
import java.io.Serializable;
class Test {
public static void main(String[] args) {
static void bar(boolean flag) {
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);
}
foo(0, flag ? a : b<caret>);
}
static void foo(int x, Serializable... xs) {
}
@@ -0,0 +1,11 @@
// "Replace with 'new Object[]{getObject(/*empty*/)}'" "true"
class Test {
static void foo(Object... data) { }
void test(boolean b, Object[] obj2) {
foo(b ? getObject(/*empty*/<caret>) : obj2);
}
native Object getObject();
}
@@ -0,0 +1,15 @@
// "Replace with 'new Object[]{b}'" "true"
class Test {
static void bar(boolean flag) {
Integer[] a = {1, 2};
Integer b = 42;
foo(0, (((flag ? a : b<caret>))));
}
static void foo(int x, Object... xs) {
}
public static void main(String[] args) {
bar(true);
}
}