You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2020/07/10 08:41:44 UTC
[groovy] 03/04: Trivial refactoring: remove unnecessary check and
cast
This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch GROOVY_2_5_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 34229de585108f0cdfa2fea0b97865e9b6867901
Author: Daniel Sun <su...@apache.org>
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 7c1b889..1332deb 100644
--- a/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
+++ b/src/main/java/org/codehaus/groovy/classgen/VariableScopeVisitor.java
@@ -532,13 +532,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);