From 5b154fff5a4339ae65fd8e54ce68f2d61a865807 Mon Sep 17 00:00:00 2001 From: Daniel Sun Date: Fri, 10 Jan 2025 21:55:45 +0900 Subject: [PATCH] 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 1644fabc7b8..013d1451ec9 100644 --- a/src/main/java/groovy/lang/MetaClassImpl.java +++ b/src/main/java/groovy/lang/MetaClassImpl.java @@ -3740,7 +3740,6 @@ protected MetaMethod findMixinMethod(String methodName, Class[] arguments) { } 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 @@ protected static MetaMethod findMethodInClassHierarchy(Class instanceKlazz, Stri } } - 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); }