}
if (o instanceof MetaMethod) {
MetaMethod match = (MetaMethod) o;
if (!isMatchingMethod(match, method)) {
FastArray list = new FastArray(2);
list.add(match);
list.add(method);
return list;
} else {
if (match.isPrivate()
|| (!isNonRealMethod(match) && match.getDeclaringClass().isInterface() && !method.getDeclaringClass().isInterface())) {
// do not overwrite interface methods with instance methods
// do not overwrite private methods
// Note: private methods from parent classes are not shown here,
// but when doing the multimethod connection step, we overwrite
// methods of the parent class with methods of a subclass and
// in that case we want to keep the private methods
} else {
CachedClass methodC = method.getDeclaringClass();
CachedClass matchC = match.getDeclaringClass();
if (methodC == matchC) {
if (isNonRealMethod(method)) {
return method;
}
} else if (!methodC.isAssignableFrom(matchC.getTheClass())) {
return method;
}
}
}
return o;
}
if (o instanceof FastArray) {
FastArray list = (FastArray) o;
int found = findMatchingMethod(list, method);
if (found == -1) {
list.add(method);
} else {
MetaMethod match = (MetaMethod) list.get(found);
if (match==method) return o;
if (match.isPrivate()
|| (!isNonRealMethod(match) && match.getDeclaringClass().isInterface() && !method.getDeclaringClass().isInterface())) {
// do not overwrite interface methods with instance methods
// do not overwrite private methods
// Note: private methods from parent classes are not shown here,
// but when doing the multimethod connection step, we overwrite
// methods of the parent class with methods of a subclass and
// in that case we want to keep the private methods
} else {
CachedClass methodC = method.getDeclaringClass();
CachedClass matchC = match.getDeclaringClass();
if (methodC == matchC) {
if (isNonRealMethod(method)) {
list.set(found, method);
}
} else if (!methodC.isAssignableFrom(matchC.getTheClass())) {
list.set(found, method);
}
}
}
}