mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 22:51:17 +07:00
inline: substitute ellipsis type before array construction (IDEA-65897)
This commit is contained in:
@@ -606,9 +606,9 @@ public class InlineMethodProcessor extends BaseRefactoringProcessor {
|
||||
@NonNls String defaultValue;
|
||||
if (paramType instanceof PsiEllipsisType) {
|
||||
final PsiEllipsisType ellipsisType = (PsiEllipsisType)paramType;
|
||||
paramType = ellipsisType.toArrayType();
|
||||
paramType = callSubstitutor.substitute(ellipsisType.toArrayType());
|
||||
if (applicabilityLevel == MethodCandidateInfo.ApplicabilityLevel.VARARGS) {
|
||||
defaultValue = "new " + ellipsisType.getComponentType().getCanonicalText() + "[]{}";
|
||||
defaultValue = "new " + ((PsiArrayType)paramType).getComponentType().getCanonicalText() + "[]{}";
|
||||
}
|
||||
else {
|
||||
defaultValue = PsiTypesUtil.getDefaultValueOfType(paramType);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
<T> void doSmth(T... ps) {
|
||||
System.out.println(ps);
|
||||
}
|
||||
|
||||
void m() {
|
||||
doS<caret>mth(1, 2, 3);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
|
||||
void m() {
|
||||
System.out.println(new Integer[]{1, 2, 3});
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,10 @@ public class InlineMethodTest extends LightCodeInsightTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testArrayTypeInferenceFromVarargs() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
String name = getTestName(false);
|
||||
@NonNls String fileName = "/refactoring/inlineMethod/" + name + ".java";
|
||||
|
||||
Reference in New Issue
Block a user