MCPcopy Index your code
hub / github.com/apache/groovy / mostSpecific

Method mostSpecific

src/main/java/groovy/lang/MetaClassImpl.java:4053–4069  ·  view source on GitHub ↗
(MetaMethod method, MetaMethod newMethod, Class instanceKlazz)

Source from the content-addressed store, hash-verified

4051 }
4052
4053 private static MetaMethod mostSpecific(MetaMethod method, MetaMethod newMethod, Class instanceKlazz) {
4054 Class<?> newMethodC = newMethod.getDeclaringClass().getTheClass();
4055 if (!newMethodC.isAssignableFrom(instanceKlazz)) {
4056 return method;
4057 }
4058 Class<?> methodC = method.getDeclaringClass().getTheClass();
4059 if (newMethodC == methodC) {
4060 return newMethod;
4061 }
4062 if (newMethodC.isAssignableFrom(methodC)) {
4063 return method;
4064 }
4065 if (methodC.isAssignableFrom(newMethodC)) {
4066 return newMethod;
4067 }
4068 return newMethod;
4069 }
4070
4071 /**
4072 * Chooses the best method declared directly on the supplied meta class.

Callers 3

getMetaMethodMethod · 0.95
findSubClassMethodMethod · 0.95
findOwnMethodMethod · 0.95

Calls 3

getTheClassMethod · 0.65
getDeclaringClassMethod · 0.45
isAssignableFromMethod · 0.45

Tested by

no test coverage detected