mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
collect exceptions by call arguments (IDEA-134808)
This commit is contained in:
@@ -107,7 +107,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
|
||||
final List<PsiClassType> exceptions = ExceptionUtil.ourThrowsGuard.doPreventingRecursion(myExpression, false, new Computable<List<PsiClassType>>() {
|
||||
@Override
|
||||
public List<PsiClassType> compute() {
|
||||
return ExceptionUtil.getUnhandledExceptions(body);
|
||||
return ExceptionUtil.getUnhandledExceptions(new PsiElement[] {body});
|
||||
}
|
||||
});
|
||||
if (exceptions != null) {
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
import java.io.File;
|
||||
|
||||
class Test {
|
||||
public interface A<E extends Throwable> {
|
||||
Object call() throws E;
|
||||
}
|
||||
|
||||
public interface B<E extends Throwable> {
|
||||
void call() throws E;
|
||||
}
|
||||
|
||||
static <T, E extends Throwable> T method(A<E> lambda) {
|
||||
try {
|
||||
lambda.call();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static <E extends Throwable> void method(B<E> lambda) {
|
||||
try {
|
||||
lambda.call();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static String returns(String s) throws Exception {
|
||||
System.out.println(s); return null;
|
||||
}
|
||||
|
||||
static void voids(String s) throws Exception {
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
static {
|
||||
|
||||
method(() -> {
|
||||
voids("B");
|
||||
});
|
||||
method(() -> voids("B"));
|
||||
|
||||
method(() -> {
|
||||
return new File(returns("A"));
|
||||
});
|
||||
method(() -> new File(returns("A")));
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,10 @@ public class ExceptionVariablesInferenceTest extends LightDaemonAnalyzerTestCase
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExceptionsThrownByCallArguments() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user