From 83db0799683c75a5e7ea7f30300155e46dd50dd4 Mon Sep 17 00:00:00 2001 From: theraven Date: Thu, 14 Jul 2011 17:41:36 +0000 Subject: [PATCH] Fix bug in fast path for class_getInstanceMethod() --- runtime.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/runtime.c b/runtime.c index 390d4a1..447cb2b 100644 --- a/runtime.c +++ b/runtime.c @@ -353,8 +353,15 @@ Method class_getInstanceMethod(Class aClass, SEL aSelector) if (classHasInstalledDtable(aClass)) { // Do a dtable lookup to find out which class the method comes from. - struct objc_slot *slot = objc_get_slot(aClass->isa, aSelector); - if (NULL == slot) { return NULL; } + struct objc_slot *slot = objc_get_slot(aClass, aSelector); + 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. 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; } SEL sel = sel_registerTypedName_np(sel_getName(name), types); Method method = class_getInstanceMethodNonrecursive(cls, sel); - //fprintf(stderr, "Found %p looking for [%s %s]\n", method, cls->name, sel_getName(sel)); if (method == NULL) { class_addMethod(cls, sel, imp, types);