groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] 08/09: trivial refactor
Date Mon, 11 Nov 2019 05:59:22 GMT
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 9d6e21f6cd0318f6f494ad4cb4238caccaa0e9d9
Author: Eric Milles <eric.milles@thomsonreuters.com>
AuthorDate: Sun Nov 10 21:22:43 2019 -0600

    trivial refactor
---
 .../groovy/transform/stc/StaticTypeCheckingVisitor.java | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
index e0f3da3..b032191 100644
--- a/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
+++ b/src/main/java/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java
@@ -4171,7 +4171,7 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
 
     @Override
     public void visitTryCatchFinally(final TryCatchStatement statement) {
-        final List<CatchStatement> catchStatements = statement.getCatchStatements();
+        List<CatchStatement> catchStatements = statement.getCatchStatements();
         for (CatchStatement catchStatement : catchStatements) {
             ClassNode exceptionType = catchStatement.getExceptionType();
             typeCheckingContext.controlStructureVariables.put(catchStatement.getVariable(),
exceptionType);
@@ -4183,16 +4183,17 @@ public class StaticTypeCheckingVisitor extends ClassCodeVisitorSupport
{
                 typeCheckingContext.controlStructureVariables.remove(catchStatement.getVariable());
             }
         }
-
     }
 
     protected void storeType(final Expression exp, ClassNode cn) {
-        if (exp instanceof VariableExpression && ((VariableExpression) exp).isClosureSharedVariable()
&& isPrimitiveType(cn)) {
-            cn = getWrapper(cn);
-        } else if (exp instanceof MethodCallExpression && ((MethodCallExpression)
exp).isSafe() && isPrimitiveType(cn)) {
-            cn = getWrapper(cn);
-        } else if (exp instanceof PropertyExpression && ((PropertyExpression) exp).isSafe()
&& isPrimitiveType(cn)) {
-            cn = getWrapper(cn);
+        if (cn != null && isPrimitiveType(cn)) {
+            if (exp instanceof VariableExpression && ((VariableExpression) exp).isClosureSharedVariable())
{
+                cn = getWrapper(cn);
+            } else if (exp instanceof MethodCallExpression && ((MethodCallExpression)
exp).isSafe()) {
+                cn = getWrapper(cn);
+            } else if (exp instanceof PropertyExpression && ((PropertyExpression)
exp).isSafe()) {
+                cn = getWrapper(cn);
+            }
         }
         if (cn == UNKNOWN_PARAMETER_TYPE) {
             // this can happen for example when "null" is used in an assignment or a method
parameter.


Mime
View raw message