mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
inference: proper exceptions thrown checks (IDEA-152577)
This commit is contained in:
@@ -161,7 +161,7 @@ public class CheckedExceptionCompatibilityConstraint extends InputOutputConstrai
|
||||
|
||||
private static boolean isAddressed(List<PsiType> expectedThrownTypes, PsiType thrownType) {
|
||||
for (PsiType expectedThrownType : expectedThrownTypes) {
|
||||
if (TypeConversionUtil.isAssignable(TypeConversionUtil.erasure(thrownType), expectedThrownType)) {
|
||||
if (TypeConversionUtil.isAssignable(expectedThrownType, thrownType)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import java.io.IOException;
|
||||
|
||||
class GenericException {
|
||||
{
|
||||
applyFunc(t -> throwsException());
|
||||
}
|
||||
|
||||
private static <T, E extends Exception> void applyFunc(CheckedFunction<T, E> function) {}
|
||||
|
||||
|
||||
private static void throwsException() throws Exception {}
|
||||
|
||||
interface CheckedFunction<T, E extends Exception> {
|
||||
void apply(T t) throws E, IOException;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -63,6 +63,10 @@ public class ConstraintsInferenceMiscTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testExceptionConstraintsWithProperAndNonProperThrows() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest(final boolean checkWarnings) {
|
||||
doTest(BASE_PATH + "/" + getTestName(false) + ".java", checkWarnings, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user