Skip to content

Commit b7ead9c

Browse files
authored
use superclass's forwardInvocation implementation when aspect_undoSwizzleForwardInvocation
1 parent a80273d commit b7ead9c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Aspects.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,9 @@ static void aspect_swizzleForwardInvocation(Class klass) {
401401
static void aspect_undoSwizzleForwardInvocation(Class klass) {
402402
NSCParameterAssert(klass);
403403
Method originalMethod = class_getInstanceMethod(klass, NSSelectorFromString(AspectsForwardInvocationSelectorName));
404-
Method objectMethod = class_getInstanceMethod(NSObject.class, @selector(forwardInvocation:));
405-
// There is no class_removeMethod, so the best we can do is to retore the original implementation, or use a dummy.
406-
IMP originalImplementation = method_getImplementation(originalMethod ?: objectMethod);
404+
Method superClassMethod = class_getInstanceMethod(class_getSuperclass(klass) ?: NSObject.class, @selector(forwardInvocation:));
405+
// There is no class_removeMethod, so the best we can do is to retore the original implementation, or use superclass's.
406+
IMP originalImplementation = method_getImplementation(originalMethod ?: superClassMethod);
407407
class_replaceMethod(klass, @selector(forwardInvocation:), originalImplementation, "v@:@");
408408

409409
AspectLog(@"Aspects: %@ has been restored.", NSStringFromClass(klass));

0 commit comments

Comments
 (0)