delegate methods: restore ellipsis type (IDEA-171529)

This commit is contained in:
Anna.Kozlova
2017-04-18 15:03:44 +02:00
parent 7a23d509b8
commit 9f6e8ccb35
4 changed files with 28 additions and 1 deletions
@@ -451,7 +451,11 @@ public class GenerateMembersUtil {
paramName = generator.generateUniqueName(paramName);
}
generator.addExistingName(paramName);
result[i] = factory.createParameter(paramName, GenericsUtil.getVariableTypeByExpressionType(substituted), target);
PsiType expressionType = GenericsUtil.getVariableTypeByExpressionType(substituted);
if (expressionType instanceof PsiArrayType && substituted instanceof PsiEllipsisType) {
expressionType = new PsiEllipsisType(((PsiArrayType)expressionType).getComponentType());
}
result[i] = factory.createParameter(paramName, expressionType, target);
}
return result;
}
@@ -0,0 +1,11 @@
class Foo {
void foo(String... s) {}
}
class Bar {
Foo myDelegate;
public void foo(String... s) {
myDelegate.foo(s);
}
}
@@ -0,0 +1,8 @@
class Foo {
void foo(String... s) {}
}
class Bar {
Foo myDelegate;
<caret>
}
@@ -100,6 +100,10 @@ public class DelegateMethodsTest extends LightCodeInsightTestCase {
doTest();
}
public void testPreserveEllipsisType() throws Exception {
doTest();
}
private void doTest() throws Exception {
doTest(getTestName(false));
}