diff --git a/teavm-core/src/main/java/org/teavm/javascript/OptimizingVisitor.java b/teavm-core/src/main/java/org/teavm/javascript/OptimizingVisitor.java index 60e720691..f1dfa0009 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/OptimizingVisitor.java +++ b/teavm-core/src/main/java/org/teavm/javascript/OptimizingVisitor.java @@ -551,8 +551,12 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor { @Override public void visit(TryCatchStatement statement) { - processSequence(statement.getProtectedBody()); - processSequence(statement.getHandler()); + List statements = processSequence(statement.getProtectedBody()); + statement.getProtectedBody().clear(); + statement.getProtectedBody().addAll(statements); + statements = processSequence(statement.getHandler()); + statement.getHandler().clear(); + statement.getHandler().addAll(statements); resultStmt = statement; } }