groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 17/18: Trivial refactoring: remove unnecessary check and cast
Date Sun, 03 Nov 2019 15:42:33 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit d339c8825a8763df90aebda0fe5c3885c1bec0df
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Sun Nov 3 23:11:52 2019 +0800

    Trivial refactoring: remove unnecessary check and cast
    
    (cherry picked from commit ed33b22fe20134569063bf03989d5516f9a51e34)
---
 .../java/org/codehaus/groovy/classgen/VariableScopeVisitor.java    | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java b/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
index e6ffc6f..8d4a738 100644
--- a/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
@@ -518,13 +518,12 @@ public class VariableScopeVisitor extends ClassCodeVisitorSupport {
     public void visitMethodCallExpression(MethodCallExpression call) {
         if (call.isImplicitThis() && call.getMethod() instanceof ConstantExpression)
{
             ConstantExpression methodNameConstant = (ConstantExpression) call.getMethod();
-            Object value = methodNameConstant.getText();
+            String methodName = methodNameConstant.getText();
 
-            if (!(value instanceof String)) {
-                throw new GroovyBugError("tried to make a method call with a non-String constant
method name.");
+            if (methodName == null) {
+                throw new GroovyBugError("method name is null");
             }
 
-            String methodName = (String) value;
             Variable v = checkVariableNameForDeclaration(methodName, call);
             if (v != null && !(v instanceof DynamicVariable)) {
                 checkVariableContextAccess(v, call);


Mime
View raw message