Java: Don't report the catch section as unreachable where a subclass of declared exception can be thrown (IDEA-175863)

This commit is contained in:
Pavel Dolgov
2017-07-18 14:25:32 +03:00
parent 1a50059f81
commit 7d30d532c6
3 changed files with 26 additions and 1 deletions
@@ -0,0 +1,23 @@
class C {
void foo(boolean b) throws Exception {
try {
if (b) {
throw new ChildException();
} else {
method();
}
} catch (ChildException e) {
System.out.println("child");
} catch (ParentException e) {
System.out.println("parent");
}
}
private static void method() throws Exception {
throw new ParentException();
}
static class ParentException extends Exception { }
static class ChildException extends ParentException { }
}