mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
inline: don't flatten multi dimensional array in varargs calls (IDEA-153700)
This commit is contained in:
@@ -295,6 +295,11 @@ public class InlineUtil {
|
||||
}
|
||||
|
||||
private static boolean isSafeToFlatten(PsiCall callExpression, PsiMethod oldRefMethod, PsiExpression[] arrayElements) {
|
||||
for (PsiExpression arrayElement : arrayElements) {
|
||||
if (arrayElement instanceof PsiArrayInitializerExpression) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
PsiCall copy = (PsiCall)callExpression.copy();
|
||||
PsiExpressionList copyArgumentList = copy.getArgumentList();
|
||||
LOG.assertTrue(copyArgumentList != null);
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Object[][] pa<caret>rams = new Object[][]{{""}, {""}};
|
||||
List<Object[]> l1 = Arrays.asList(params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
class Main {
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<Object[]> l1 = Arrays.asList(new Object[][]{{""}, {""}});
|
||||
}
|
||||
}
|
||||
@@ -260,6 +260,10 @@ public class InlineLocalTest extends LightCodeInsightTestCase {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testDontOpenMultidimensionalArrays() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testLocalVarInsideLambdaBodyWriteUsage() throws Exception {
|
||||
doTest(true, "Cannot perform refactoring.\n" +
|
||||
"Variable 'hello' is accessed for writing");
|
||||
|
||||
Reference in New Issue
Block a user