mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
recursive getLambdaParameterType problem: don't check nested lambda body for unchecked exceptions, that's impossible anyway (IDEA-146161)
This commit is contained in:
@@ -268,6 +268,9 @@ public class ExceptionUtil {
|
||||
else if (element instanceof PsiMethodReferenceExpression) {
|
||||
unhandledExceptions = getUnhandledExceptions((PsiMethodReferenceExpression)element, topElement);
|
||||
}
|
||||
else if (element instanceof PsiLambdaExpression) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
else if (element instanceof PsiThrowStatement) {
|
||||
PsiThrowStatement statement = (PsiThrowStatement)element;
|
||||
unhandledExceptions = getUnhandledExceptions(statement, topElement);
|
||||
@@ -326,7 +329,13 @@ public class ExceptionUtil {
|
||||
}
|
||||
|
||||
for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
|
||||
foundExceptions = collectUnhandledExceptions(child, topElement, foundExceptions, includeSelfCalls);
|
||||
Set<PsiClassType> foundInChild = collectUnhandledExceptions(child, topElement, foundExceptions, includeSelfCalls);
|
||||
if (foundExceptions == null) {
|
||||
foundExceptions = foundInChild;
|
||||
}
|
||||
else if (foundInChild != null) {
|
||||
foundExceptions.addAll(foundInChild);
|
||||
}
|
||||
}
|
||||
|
||||
return foundExceptions;
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
class Test {
|
||||
|
||||
Optional<String> getOptionalAssigneeId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void getById(Optional<Test> join, CompletableFuture<Void> voidCompletableFuture) {
|
||||
voidCompletableFuture.thenApply(v -> {
|
||||
return join.map(caze -> {
|
||||
caze.getOptionalAssigneeId().map(id -> {
|
||||
String s = id;
|
||||
return null;
|
||||
});
|
||||
return null;
|
||||
});
|
||||
}).join();
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ class Test {
|
||||
IntStream mi = sp.map(Inner::foo);
|
||||
Stream<Integer> mI = sp.map(Inner::fooBoxed);
|
||||
|
||||
IntStream li = sp.<error descr="Ambiguous method call: both 'Stream.map(Function<? super Inner, ? extends R>)' and 'Stream.map(IntFunction<? super Inner>)' match">map</error>(inner->inner.<error descr="Cannot resolve method 'foo()'">foo</error>());
|
||||
IntStream li = sp.<error descr="Cannot resolve method 'map(<lambda expression>)'">map</error>(inner->inner.<error descr="Cannot resolve method 'foo()'">foo</error>());
|
||||
Stream<Integer> lI = sp.<error descr="Ambiguous method call: both 'Stream.map(Function<? super Inner, ? extends Integer>)' and 'Stream.map(IntFunction<? super Inner>)' match">map</error>(inner -> inner.<error descr="Cannot resolve method 'fooBoxed()'">fooBoxed</error>());
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,10 @@ public class Java8ExpressionsCheckTest extends LightDaemonAnalyzerTestCase {
|
||||
doTestAllMethodCallExpressions();
|
||||
}
|
||||
|
||||
public void testDontCollectUnhandledReferencesInsideLambdaBody() throws Exception {
|
||||
doTestAllMethodCallExpressions();
|
||||
}
|
||||
|
||||
public void testCachedUnresolvedMethods() throws Exception {
|
||||
doTestCachedUnresolved();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user