Fix bug in fast path for class_getInstanceMethod()

main
theraven 15 years ago
parent 65d6a8dfb5
commit 83db079968

@ -353,8 +353,15 @@ Method class_getInstanceMethod(Class aClass, SEL aSelector)
if (classHasInstalledDtable(aClass)) if (classHasInstalledDtable(aClass))
{ {
// Do a dtable lookup to find out which class the method comes from. // Do a dtable lookup to find out which class the method comes from.
struct objc_slot *slot = objc_get_slot(aClass->isa, aSelector); struct objc_slot *slot = objc_get_slot(aClass, aSelector);
if (NULL == slot) { return NULL; } if (NULL == slot)
{
slot = objc_get_slot(aClass, sel_registerName(sel_getName(aSelector)));
if (NULL == slot)
{
return NULL;
}
}
// Now find the typed variant of the selector, with the correct types. // Now find the typed variant of the selector, with the correct types.
aSelector = slot->selector; aSelector = slot->selector;
@ -450,7 +457,6 @@ IMP class_replaceMethod(Class cls, SEL name, IMP imp, const char *types)
if (Nil == cls) { return (IMP)0; } if (Nil == cls) { return (IMP)0; }
SEL sel = sel_registerTypedName_np(sel_getName(name), types); SEL sel = sel_registerTypedName_np(sel_getName(name), types);
Method method = class_getInstanceMethodNonrecursive(cls, sel); Method method = class_getInstanceMethodNonrecursive(cls, sel);
//fprintf(stderr, "Found %p looking for [%s %s]\n", method, cls->name, sel_getName(sel));
if (method == NULL) if (method == NULL)
{ {
class_addMethod(cls, sel, imp, types); class_addMethod(cls, sel, imp, types);

Loading…
Cancel
Save