This is an automated email from the ASF dual-hosted git repository. sunlan pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/groovy.git
commit ed33b22fe20134569063bf03989d5516f9a51e34 Author: Daniel Sun <[email protected]> AuthorDate: Sun Nov 3 23:11:52 2019 +0800 Trivial refactoring: remove unnecessary check and cast --- .../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);
