mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
lambda: do not warn about unhandled exceptions from lambda on call site
This commit is contained in:
@@ -524,6 +524,9 @@ public class ExceptionUtil {
|
||||
// like in void f() throws XXX { new AA(methodThrowingXXX()) { ... }; }
|
||||
return parent instanceof PsiAnonymousClass && isHandled(parent, exceptionType, topElement);
|
||||
}
|
||||
else if (parent instanceof PsiLambdaExpression) {
|
||||
return true;
|
||||
}
|
||||
else if (parent instanceof PsiClassInitializer) {
|
||||
if (((PsiClassInitializer)parent).hasModifierProperty(PsiModifier.STATIC)) return false;
|
||||
// anonymous class initializers can throw any exceptions
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import java.io.IOException;
|
||||
|
||||
interface Callable<V> {
|
||||
V call() throws Exception;
|
||||
}
|
||||
|
||||
class Test2 {
|
||||
static <V> void m(Callable<V> c){}
|
||||
{
|
||||
m(() -> {throw new IOException();});
|
||||
}
|
||||
}
|
||||
@@ -99,6 +99,10 @@ public class LambdaHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testUnhandledException() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", false, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user