diff --git a/java/java-impl/src/com/intellij/codeInsight/editorActions/smartEnter/MethodCallFixer.java b/java/java-impl/src/com/intellij/codeInsight/editorActions/smartEnter/MethodCallFixer.java index 62a62efbd6dd..417d21d39aba 100644 --- a/java/java-impl/src/com/intellij/codeInsight/editorActions/smartEnter/MethodCallFixer.java +++ b/java/java-impl/src/com/intellij/codeInsight/editorActions/smartEnter/MethodCallFixer.java @@ -93,7 +93,7 @@ public class MethodCallFixer implements Fixer { int paramCount = Integer.MAX_VALUE; for (CandidateInfo candidate : PsiResolveHelper.SERVICE.getInstance(call.getProject()).getReferencedMethodCandidates(call, false)) { PsiElement element = candidate.getElement(); - if (element instanceof PsiMethod) { + if (element instanceof PsiMethod && !((PsiMethod)element).isVarArgs()) { paramCount = Math.min(paramCount, ((PsiMethod)element).getParameterList().getParametersCount()); } } diff --git a/java/java-tests/testData/codeInsight/completeStatement/VarargMethod.java b/java/java-tests/testData/codeInsight/completeStatement/VarargMethod.java new file mode 100644 index 000000000000..1f40a149e039 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completeStatement/VarargMethod.java @@ -0,0 +1,6 @@ +public class VarargMethod { + void test() { + List list = new ArrayList<>(); + list.add(String.format("m", p1, p2) + } +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/completeStatement/VarargMethod_after.java b/java/java-tests/testData/codeInsight/completeStatement/VarargMethod_after.java new file mode 100644 index 000000000000..1bdb4593e423 --- /dev/null +++ b/java/java-tests/testData/codeInsight/completeStatement/VarargMethod_after.java @@ -0,0 +1,6 @@ +public class VarargMethod { + void test() { + List list = new ArrayList<>(); + list.add(String.format("m", p1, p2)); + } +} \ No newline at end of file diff --git a/java/java-tests/testSrc/com/intellij/java/codeInsight/CompleteStatementTest.java b/java/java-tests/testSrc/com/intellij/java/codeInsight/CompleteStatementTest.java index 58f35794be88..1df53e31c617 100644 --- a/java/java-tests/testSrc/com/intellij/java/codeInsight/CompleteStatementTest.java +++ b/java/java-tests/testSrc/com/intellij/java/codeInsight/CompleteStatementTest.java @@ -181,6 +181,7 @@ public class CompleteStatementTest extends EditorActionTestCase { public void testRecord() { doTest(); } public void testRecordWithComponent() { doTest(); } public void testRecordWithComponentNoBody() { doTest(); } + public void testVarargMethod() { doTest(); } private void doTestBracesNextLineStyle() { myJavaSettings.BRACE_STYLE = CommonCodeStyleSettings.NEXT_LINE;