You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/11/03 15:42:33 UTC

[groovy] 17/18: Trivial refactoring: remove unnecessary check and cast

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 <su...@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);