mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
overload resolution: proceed with additional constraints when qualifier type is calculated (IDEA-151409)
This commit is contained in:
+16
-1
@@ -359,7 +359,7 @@ public class InferenceSession {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parameters != null && args != null && !MethodCandidateInfo.isOverloadCheck()) {
|
||||
if (parameters != null && args != null && !isOverloadCheck()) {
|
||||
final Set<ConstraintFormula> additionalConstraints = new LinkedHashSet<ConstraintFormula>();
|
||||
if (parameters.length > 0) {
|
||||
collectAdditionalConstraints(parameters, args, properties.getMethod(), mySiteSubstitutor, additionalConstraints, properties.isVarargs(), initialSubstitutor);
|
||||
@@ -396,6 +396,21 @@ public class InferenceSession {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isOverloadCheck() {
|
||||
if (myContext != null) {
|
||||
for (Object o : MethodCandidateInfo.ourOverloadGuard.currentStack()) {
|
||||
final PsiExpressionList element = (PsiExpressionList)o;
|
||||
for (PsiExpression expression : element.getExpressions()) {
|
||||
if (expression == myContext) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return MethodCandidateInfo.isOverloadCheck();
|
||||
}
|
||||
|
||||
private void collectAdditionalConstraints(PsiParameter[] parameters,
|
||||
PsiExpression[] args,
|
||||
PsiMethod parentMethod,
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class Main {
|
||||
|
||||
private void <warning descr="Private method 'createFunction(java.util.stream.Stream<java.util.Set<java.lang.String>>)' is never used">createFunction</warning>(Stream<Set<String>> setStream) {
|
||||
foo (setStream.flatMap(Collection::stream).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private void foo(Collection<String> keys) {
|
||||
System.out.println(keys);
|
||||
}
|
||||
private void <warning descr="Private method 'foo(java.util.Set<java.lang.String>)' is never used">foo</warning>(Set<String> keys) {
|
||||
System.out.println(keys);
|
||||
}
|
||||
|
||||
}
|
||||
+4
@@ -208,6 +208,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testTypeCalculationOfQualifierShouldNotDependOnOverloadResolutionOfContainingMethodCall() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user