inference: don't traverse up through lambda bounds when parent inference was already started, in this case it's exception inference which should work without top level node (EA-83073 - assert: LambdaUtil.treeWalkUp; IDEA-173467)

This commit is contained in:
Anna Kozlova
2017-05-26 13:15:15 +03:00
parent da7f6704cc
commit 51bcfcecf9
3 changed files with 38 additions and 2 deletions

View File

@@ -771,8 +771,7 @@ public class LambdaUtil {
}
final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(psiCall.getArgumentList());
if (properties != null) {
if (properties.isApplicabilityCheck() ||
lambdaExpression != null && lambdaExpression.hasFormalParameterTypes()) {
if (properties.isApplicabilityCheck() || lambdaExpression != null) {
break;
}
}

View File

@@ -0,0 +1,33 @@
package foo;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
class Test {
public void setup(OngoingStubbing<Map<String, List<String>>> stubbing) throws ReflectiveOperationException {
stubbing.thenAnswer(inv -> to<caret>Map((Collection) inv.getArguments()[0], periodic((String) null)));
}
private <K, V> Map<K, V> toMap(Collection<K> keys, V v) {
return Collections.emptyMap();
}
private <T> List<T> periodic(T t) throws ReflectiveOperationException {
return null;
}
}
abstract class OngoingStubbing<T> {
abstract OngoingStubbing<T> thenAnswer(Answer<?> answer);
}
interface Answer<T> {
T answer(InvocationOnMock invocation) throws Throwable;
}
interface InvocationOnMock {
Object[] getArguments();
}

View File

@@ -138,6 +138,10 @@ public class Java8ExpressionsCheckTest extends LightDaemonAnalyzerTestCase {
doTestConfiguredFile(false, false, filePath);
}
public void testCheckedExceptionConstraintToTopLevel() throws Exception {
doTestCachedUnresolved();
}
private void doTestCachedUnresolved() {
configureByFile(BASE_PATH + "/" + getTestName(false) + ".java");
PsiMethodCallExpression callExpression =