Skip to content

Commit

Permalink
Trivial refactoring: extract variable
Browse files Browse the repository at this point in the history
(cherry picked from commit 2ddb72c)
  • Loading branch information
daniellansun committed Jan 12, 2025
1 parent 0fc66ef commit 5b154ff
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/main/java/groovy/lang/MetaClassImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand All @@ -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);
}
Expand Down

0 comments on commit 5b154ff

Please sign in to comment.