This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/GROOVY_4_0_X by this push:
     new 5b154fff5a Trivial refactoring: extract variable
5b154fff5a is described below

commit 5b154fff5a4339ae65fd8e54ce68f2d61a865807
Author: Daniel Sun <[email protected]>
AuthorDate: Fri Jan 10 21:55:45 2025 +0900

    Trivial refactoring: extract variable
    
    (cherry picked from commit 2ddb72c4a45f861a99e076040691c06ce8f0d1cd)
---
 src/main/java/groovy/lang/MetaClassImpl.java | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/main/java/groovy/lang/MetaClassImpl.java 
b/src/main/java/groovy/lang/MetaClassImpl.java
index 1644fabc7b..013d1451ec 100644
--- a/src/main/java/groovy/lang/MetaClassImpl.java
+++ b/src/main/java/groovy/lang/MetaClassImpl.java
@@ -3740,7 +3740,6 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
     }
 
     protected static MetaMethod findMethodInClassHierarchy(Class 
instanceKlazz, String methodName, Class[] arguments, MetaClass metaClass) {
-
         if (metaClass instanceof MetaClassImpl) {
             boolean check = false;
             for (ClassInfo ci : ((MetaClassImpl) 
metaClass).theCachedClass.getHierarchy()) {
@@ -3751,24 +3750,23 @@ public class MetaClassImpl implements MetaClass, 
MutableMetaClass {
                 }
             }
 
-            if (!check)
-                return null;
+            if (!check) return null;
         }
 
-        MetaMethod method = null;
-
-        Class superClass;
-        if (metaClass.getTheClass().isArray() && 
!metaClass.getTheClass().getComponentType().isPrimitive() && 
metaClass.getTheClass().getComponentType() != Object.class) {
+        final Class<?> superClass;
+        final Class<?> theClass = metaClass.getTheClass();
+        if (theClass.isArray() && !theClass.getComponentType().isPrimitive() 
&& theClass.getComponentType() != Object.class) {
             superClass = Object[].class;
         } else {
-            superClass = metaClass.getTheClass().getSuperclass();
+            superClass = theClass.getSuperclass();
         }
 
+        MetaMethod method = null;
         if (superClass != null) {
             MetaClass superMetaClass = 
GroovySystem.getMetaClassRegistry().getMetaClass(superClass);
             method = findMethodInClassHierarchy(instanceKlazz, methodName, 
arguments, superMetaClass);
         } else {
-            if (metaClass.getTheClass().isInterface()) {
+            if (theClass.isInterface()) {
                 MetaClass superMetaClass = 
GroovySystem.getMetaClassRegistry().getMetaClass(Object.class);
                 method = findMethodInClassHierarchy(instanceKlazz, methodName, 
arguments, superMetaClass);
             }

Reply via email to