mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: infer exceptions for inner lambda body calls (IDEA-134225)
This commit is contained in:
@@ -465,12 +465,15 @@ public class ExceptionUtil {
|
||||
final PsiLambdaExpression expression = PsiTreeUtil.getParentOfType(methodCall, PsiLambdaExpression.class);
|
||||
final PsiSubstitutor substitutor;
|
||||
if (expression != null) {
|
||||
substitutor = ourThrowsGuard.doPreventingRecursion(expression, false, new Computable<PsiSubstitutor>() {
|
||||
final PsiElement parent = methodCall.getParent();
|
||||
final boolean callInReturnStatement = parent == expression ||
|
||||
parent instanceof PsiReturnStatement && PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class, true, PsiMethod.class) == expression;
|
||||
substitutor = callInReturnStatement ? ourThrowsGuard.doPreventingRecursion(expression, false, new Computable<PsiSubstitutor>() {
|
||||
@Override
|
||||
public PsiSubstitutor compute() {
|
||||
return result.getSubstitutor();
|
||||
}
|
||||
});
|
||||
}) : result.getSubstitutor();
|
||||
} else {
|
||||
substitutor = result.getSubstitutor();
|
||||
}
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
class Test {
|
||||
|
||||
interface Extractor<T> {
|
||||
T extractData() throws IOException;
|
||||
}
|
||||
|
||||
public static <T> T query(Extractor<T> rse) {
|
||||
return null;
|
||||
}
|
||||
|
||||
static {
|
||||
final Optional<String> query = query(() -> {
|
||||
final String type = Optional.<String>empty().orElseThrow(null);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
+4
@@ -140,6 +140,10 @@ public class NewLambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testCheckedExceptionsConstraintsSubstitutionsDeepInBody() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testIDEA130129() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user