internal static MethodBase FindMostDerivedNewSlotMeth(MethodBase[] match, int cMatches)
{
int deepestHierarchy = 0;
MethodBase methWithDeepestHierarchy = null;
for (int i = 0; i < cMatches; i++)
{
// Calculate the depth of the hierarchy of the declaring type of the
// current method.
int currentHierarchyDepth = GetHierarchyDepth(match[i].DeclaringType);
// Two methods with the same hierarchy depth are not allowed. This would
// mean that there are 2 methods with the same name and sig on a given type
// which is not allowed, unless one of them is vararg...
if (currentHierarchyDepth == deepestHierarchy) {
BCLDebug.Assert(((match[i].CallingConvention & CallingConventions.VarArgs) |
(methWithDeepestHierarchy.CallingConvention & CallingConventions.VarArgs)) != 0,
"Calling conventions: " + match[i].CallingConvention + " - " + methWithDeepestHierarchy.CallingConvention);
throw new AmbiguousMatchException(Environment.GetResourceString("RFLCT.Ambiguous"));
}
// Check to see if this method is on the most derived class.
if (currentHierarchyDepth > deepestHierarchy)
{
deepestHierarchy = currentHierarchyDepth;
methWithDeepestHierarchy = match[i];
}
}
return methWithDeepestHierarchy;
}