mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
overload resolution: ensure that incorrect arg numbers are filtered and for varargs methods (IDEA-140868)
This commit is contained in:
@@ -359,8 +359,9 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
if (ignoreIfStaticsProblem && !info.isStaticsScopeCorrect()) return true;
|
||||
if (!(info instanceof MethodCandidateInfo)) continue;
|
||||
PsiMethod method = ((MethodCandidateInfo)info).getElement();
|
||||
if ((myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8) ? ((MethodCandidateInfo)info).isVarargs() : method.isVarArgs()) ||
|
||||
method.getParameterList().getParametersCount() == argumentsCount) {
|
||||
final int parametersCount = method.getParameterList().getParametersCount();
|
||||
if (((myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8) ? ((MethodCandidateInfo)info).isVarargs() : method.isVarArgs()) && parametersCount - 1 <= argumentsCount) ||
|
||||
parametersCount == argumentsCount) {
|
||||
// remove all unmatched before
|
||||
if (unmatchedIndices != null) {
|
||||
for (int u=unmatchedIndices.size()-1; u>=0; u--) {
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// "Replace with expression lambda" "true"
|
||||
|
||||
import java.io.File;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class Test {
|
||||
|
||||
{
|
||||
runWriteCommandAction(null, () -> System.out.println());
|
||||
}
|
||||
|
||||
|
||||
public static void runWriteCommandAction(String project, final Runnable runnable) {}
|
||||
public static <T> void runWriteCommandAction(String project, final Supplier<T> runnable) {}
|
||||
public static void runWriteCommandAction(String project, final String commandName, final String groupID, final Runnable runnable, File... files) {}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Replace with expression lambda" "true"
|
||||
|
||||
import java.io.File;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
class Test {
|
||||
|
||||
{
|
||||
runWriteCommandAction(null, () -> <caret>{
|
||||
System.out.println();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public static void runWriteCommandAction(String project, final Runnable runnable) {}
|
||||
public static <T> void runWriteCommandAction(String project, final Supplier<T> runnable) {}
|
||||
public static void runWriteCommandAction(String project, final String commandName, final String groupID, final Runnable runnable, File... files) {}
|
||||
}
|
||||
@@ -17,6 +17,8 @@ package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.RedundantLambdaCodeBlockInspection;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -36,4 +38,8 @@ public class RedundantLambdaCodeBlockInspectionTest extends LightQuickFixParamet
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/lambdaCodeBlock2Expr";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return IdeaTestUtil.getMockJdk18();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user