mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
new overload resolution: reject candidates with applicability level less than asked (IDEA-145505)
This commit is contained in:
@@ -272,11 +272,19 @@ public class MethodReferenceResolver implements ResolveCache.PolyVariantContextR
|
||||
|
||||
private boolean resolveConflicts(List<CandidateInfo> firstCandidates, List<CandidateInfo> secondCandidates, int applicabilityLevel) {
|
||||
|
||||
checkApplicability(firstCandidates);
|
||||
final int firstApplicability = checkApplicability(firstCandidates);
|
||||
checkSpecifics(firstCandidates, applicabilityLevel, myLanguageLevel);
|
||||
|
||||
checkApplicability(secondCandidates);
|
||||
final int secondApplicability = checkApplicability(secondCandidates);
|
||||
checkSpecifics(secondCandidates, applicabilityLevel, myLanguageLevel);
|
||||
|
||||
if (firstApplicability < secondApplicability) {
|
||||
return secondCandidates.size() == 1;
|
||||
}
|
||||
|
||||
if (secondApplicability < firstApplicability) {
|
||||
return firstCandidates.size() == 1;
|
||||
}
|
||||
|
||||
return firstCandidates.size() + secondCandidates.size() == 1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
class MyTest<T> {
|
||||
|
||||
{
|
||||
BiConsumer<Builder<T>, T> builderTBiConsumer = Builder::add;
|
||||
BiConsumer<Builder<T>, T> builderTBiConsumer1 = Builder<T>::add;
|
||||
|
||||
System.out.println(builderTBiConsumer);
|
||||
System.out.println(builderTBiConsumer1);
|
||||
}
|
||||
|
||||
public static class Builder<E> {
|
||||
|
||||
public Builder<E> add(E element) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder<E> add(E... elements) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,6 +146,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIgnoreCandidatesWithLowerApplicabilityLevel() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user