mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
inference: treeWalkUp if overload is done under current argumentList caused by lambda parameter type inference (IDEA-157676)
This commit is contained in:
@@ -69,7 +69,12 @@ public class InferenceSessionContainer {
|
||||
if (parent instanceof PsiCall) {
|
||||
final PsiExpressionList argumentList = ((PsiCall)parent).getArgumentList();
|
||||
final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
|
||||
if (properties != null && !properties.isApplicabilityCheck() && !MethodCandidateInfo.isOverloadCheck()) {
|
||||
//overload resolution can't depend on outer call => should not traverse to top
|
||||
if (properties != null && !properties.isApplicabilityCheck() &&
|
||||
//in order to to avoid caching of candidates's errors on parent (!) , so check for overload resolution is left here
|
||||
//But overload resolution can depend on type of lambda parameter. As it can't depend on lambda body,
|
||||
//traversing down would stop at lambda level and won't take into account overloaded method
|
||||
!MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argumentList)) {
|
||||
final PsiCall topLevelCall = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(parent, false,
|
||||
new Computable<PsiCall>() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
class Test {
|
||||
public void foo(Stream<String> stream) {
|
||||
stream.collect(Collectors.toMap(null, e -> bar(e)));
|
||||
}
|
||||
|
||||
public String bar(int entity) { return null; }
|
||||
public String bar(String entity) { return null; }
|
||||
}
|
||||
@@ -173,11 +173,18 @@ public class Java8ExpressionsCheckTest extends LightDaemonAnalyzerTestCase {
|
||||
doTestAllMethodCallExpressions();
|
||||
}
|
||||
|
||||
public void testOverloadResolutionInsideLambdaInsideNestedCall() throws Exception {
|
||||
doTestAllMethodCallExpressions();
|
||||
}
|
||||
|
||||
private void doTestAllMethodCallExpressions() {
|
||||
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
|
||||
final Collection<PsiCallExpression> methodCallExpressions = PsiTreeUtil.findChildrenOfType(getFile(), PsiCallExpression.class);
|
||||
for (PsiCallExpression expression : methodCallExpressions) {
|
||||
getPsiManager().dropResolveCaches();
|
||||
if (expression instanceof PsiMethodCallExpression) {
|
||||
assertNotNull("Failed to resolve: " + expression.getText(), expression.resolveMethod());
|
||||
}
|
||||
assertNotNull("Failed inference for: " + expression.getText(), expression.getType());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user