You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2021/01/14 23:00:01 UTC
[groovy] branch GROOVY-9896 updated: GROOVY-9373: allow block to
fall through to failsafe return instructions
This is an automated email from the ASF dual-hosted git repository.
emilles pushed a commit to branch GROOVY-9896
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY-9896 by this push:
new 4e4235e GROOVY-9373: allow block to fall through to failsafe return instructions
4e4235e is described below
commit 4e4235eb7f916c124b2d3c451b80173311d75c07
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Jan 14 16:59:48 2021 -0600
GROOVY-9373: allow block to fall through to failsafe return instructions
---
.../org/codehaus/groovy/classgen/ReturnAdder.java | 20 +-------------------
1 file changed, 1 insertion(+), 19 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/classgen/ReturnAdder.java b/src/main/java/org/codehaus/groovy/classgen/ReturnAdder.java
index cf01142..a40f738 100644
--- a/src/main/java/org/codehaus/groovy/classgen/ReturnAdder.java
+++ b/src/main/java/org/codehaus/groovy/classgen/ReturnAdder.java
@@ -185,15 +185,9 @@ public class ReturnAdder {
listener.returnStatementAdded(returnStatement);
return returnStatement;
} else {
- List<Statement> statements = blockStatement.getStatements();
- int lastIndex = statements.size() - 1;
+ List<Statement> statements = blockStatement.getStatements(); int lastIndex = statements.size() - 1;
Statement last = addReturnsIfNeeded(statements.get(lastIndex), blockStatement.getVariableScope());
if (doAdd) statements.set(lastIndex, last);
- if (!returns(last)) {
- ReturnStatement returnStatement = new ReturnStatement(nullX());
- listener.returnStatementAdded(returnStatement);
- if (doAdd) statements.add(returnStatement);
- }
return blockStatement;
}
}
@@ -234,16 +228,4 @@ public class ReturnAdder {
}
return statement;
}
-
- private static boolean returns(final Statement statement) {
- return statement instanceof ReturnStatement
- || statement instanceof BlockStatement
- || statement instanceof IfStatement
- || statement instanceof ExpressionStatement
- || statement instanceof EmptyStatement
- || statement instanceof TryCatchStatement
- || statement instanceof ThrowStatement
- || statement instanceof SynchronizedStatement
- || statement instanceof BytecodeSequence;
- }
}