mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
ensure potential compatible for pertinent to applicability: when number of parameters is wrong methods which are not potentially compatible are not filtered (IDEA-149103)
This commit is contained in:
@@ -125,7 +125,7 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
|
||||
if (isToInferApplicability()) {
|
||||
//already performed checks, so if inference failed, error message should be saved
|
||||
if (myInferenceError != null) {
|
||||
if (myInferenceError != null || !isPotentiallyCompatible()) {
|
||||
return ApplicabilityLevel.NOT_APPLICABLE;
|
||||
}
|
||||
return isVarargs() ? ApplicabilityLevel.VARARGS : ApplicabilityLevel.FIXED_ARITY;
|
||||
@@ -173,8 +173,15 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
final PsiExpression[] expressions = ((PsiExpressionList)myArgumentList).getExpressions();
|
||||
|
||||
if (!isVarargs() && expressions.length != parameters.length) {
|
||||
return true;
|
||||
if (!isVarargs()) {
|
||||
if (expressions.length != parameters.length) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (expressions.length < parameters.length - 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < expressions.length; i++) {
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
class Test {
|
||||
public <T> void varargs(int i, String... p1) { }
|
||||
public <T> void usage(String p1) { }
|
||||
{
|
||||
varargs<error descr="Cannot resolve method 'varargs()'">()</error>;
|
||||
varargs(1);
|
||||
varargs(1, "");
|
||||
varargs(1, "", "");
|
||||
usage<error descr="'usage(java.lang.String)' in 'Test' cannot be applied to '()'">()</error>;
|
||||
usage("");
|
||||
usage<error descr="'usage(java.lang.String)' in 'Test' cannot be applied to '(java.lang.String, java.lang.String)'">("", "")</error>;
|
||||
}
|
||||
}
|
||||
@@ -187,6 +187,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testPotentialCompatibilityInCaseWhenNoMethodHasValidNumberOfParameters() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user