when translator: don't add break after return
This commit is contained in:
@@ -116,12 +116,11 @@ public final class WhenTranslator extends AbstractTranslator {
|
|||||||
return statementToExecute;
|
return statementToExecute;
|
||||||
}
|
}
|
||||||
JsExpression condition = translateConditions(entry);
|
JsExpression condition = translateConditions(entry);
|
||||||
return new JsIf(condition, addDummyBreak(statementToExecute), null);
|
return new JsIf(condition, addDummyBreakIfNeed(statementToExecute), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
JsStatement withReturnValueCaptured(@NotNull JsNode node) {
|
JsStatement withReturnValueCaptured(@NotNull JsNode node) {
|
||||||
|
|
||||||
return convertToStatement(LastExpressionMutator.mutateLastExpression(node,
|
return convertToStatement(LastExpressionMutator.mutateLastExpression(node,
|
||||||
new AssignToExpressionMutator(result.reference())));
|
new AssignToExpressionMutator(result.reference())));
|
||||||
}
|
}
|
||||||
@@ -172,8 +171,8 @@ public final class WhenTranslator extends AbstractTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static JsBlock addDummyBreak(@NotNull JsStatement statement) {
|
private static JsStatement addDummyBreakIfNeed(@NotNull JsStatement statement) {
|
||||||
return AstUtil.newBlock(statement, new JsBreak());
|
return statement instanceof JsReturn ? statement : AstUtil.newBlock(statement, new JsBreak());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user