mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-21 05:51:25 +07:00
method refs: do not choose more specific method between methods with different number of params
(cherry picked from commit f986c7c3541f032da16736f43fd34c92337242c4)
This commit is contained in:
@@ -609,8 +609,17 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkSameConflicts(CandidateInfo method, CandidateInfo conflict) {
|
||||
return method == conflict;
|
||||
protected boolean nonComparable(CandidateInfo method, CandidateInfo conflict) {
|
||||
if (method == conflict) return true;
|
||||
PsiElement psiElement = method.getElement();
|
||||
PsiElement conflictElement = conflict.getElement();
|
||||
if (psiElement instanceof PsiMethod && conflictElement instanceof PsiMethod) {
|
||||
if (((PsiMethod)psiElement).getParameterList().getParametersCount() !=
|
||||
((PsiMethod)conflictElement).getParameterList().getParametersCount()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
for (int j = 0; j < i; j++) {
|
||||
ProgressManager.checkCanceled();
|
||||
final CandidateInfo conflict = newConflictsArray[j];
|
||||
if (checkSameConflicts(method, conflict)) continue;
|
||||
if (nonComparable(method, conflict)) continue;
|
||||
switch (isMoreSpecific(method, conflict, applicabilityLevel, languageLevel)) {
|
||||
case FIRST:
|
||||
conflicts.remove(conflict);
|
||||
@@ -161,7 +161,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean checkSameConflicts(CandidateInfo method, CandidateInfo conflict) {
|
||||
protected boolean nonComparable(CandidateInfo method, CandidateInfo conflict) {
|
||||
assert method != conflict;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ interface Func<TIn, TOut>{
|
||||
class Main {
|
||||
|
||||
public static void main(final String[] args) {
|
||||
Func<Integer, String> func = Integer::toString;
|
||||
<error descr="Incompatible types. Found: '<method reference>', required: 'Func<java.lang.Integer,java.lang.String>'">Func<Integer, String> func = Integer::toString;</error>
|
||||
System.out.println(func.run(6));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user