public MethodResolutionResult ResolveMethodNoLock(string/*!*/ name, VisibilityContext visibility, MethodLookup options) {
Context.RequiresClassHierarchyLock();
Assert.NotNull(name);
InitializeMethodsNoLock();
RubyMemberInfo info = null;
RubyModule owner = null;
bool skipHidden = false;
bool foundCallerSelf = false;
MethodResolutionResult result;
if (ForEachAncestor((module) => {
owner = module;
foundCallerSelf |= module == visibility.Class;
return module.TryGetMethod(name, ref skipHidden, (options & MethodLookup.Virtual) != 0, out info);
})) {
if (info == null || info.IsUndefined) {
result = MethodResolutionResult.NotFound;
} else if (!IsMethodVisible(info, owner, visibility, foundCallerSelf)) {
result = new MethodResolutionResult(info, owner, false);
} else if (info.IsSuperForwarder) {
if ((options & MethodLookup.ReturnForwarder) != 0) {
result = new MethodResolutionResult(info, owner, true);
} else {
// start again with owner's super ancestor and ignore visibility:
result = owner.ResolveSuperMethodNoLock(((SuperForwarderInfo)info).SuperName, owner);
}
} else {
result = new MethodResolutionResult(info, owner, true);
}
} else {
result = MethodResolutionResult.NotFound;
}
// TODO: BasicObject
// Note: all classes include Object in ancestors, so we don't need to search it again:
if (!result.Found && (options & MethodLookup.FallbackToObject) != 0 && !IsClass) {
return _context.ObjectClass.ResolveMethodNoLock(name, visibility, options & ~MethodLookup.FallbackToObject);
}
return result;
}