ControlFlowAnalyzer: do not generate jump out of switch rule if body cannot complete normally

This commit is contained in:
Tagir Valeev
2018-12-06 15:09:32 +07:00
parent a7e71d05b6
commit a8202ddcf0
@@ -849,12 +849,13 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
boolean expressionSwitch = myExpressionBlockContext != null && myExpressionBlockContext.myCodeBlock == switchBody;
if (expressionSwitch && body instanceof PsiExpressionStatement) {
myExpressionBlockContext.generateReturn(((PsiExpressionStatement)body).getExpression(), this);
}
if (body != null) {
body.accept(this);
}
if (!(body instanceof PsiThrowStatement)) {
jumpOut(expressionSwitch ? switchBody : switchBlock);
} else {
if (body != null) {
body.accept(this);
}
if (ControlFlowUtils.statementMayCompleteNormally(body)) {
jumpOut(expressionSwitch ? switchBody : switchBlock);
}
}
finishElement(statement);
}