diff --git a/ChangeLog b/ChangeLog index b17082ab6..8e95e240e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-11-24 Richard Frith-Macdonald + + * Source/NSObject.m: ([methodSignatureForSelector:]) Check that the + types of the selector (if known) and the types of the actual method + match. Raise an NSInternalInconsistencyException if they don't. + 2008-11-23 Richard Frith-Macdonald * Source/Additions/unicode/gsm0338.h: Add more mappings from unicode diff --git a/Source/NSObject.m b/Source/NSObject.m index e7b112cb2..4f63ef7c6 100644 --- a/Source/NSObject.m +++ b/Source/NSObject.m @@ -1599,6 +1599,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel) */ - (NSMethodSignature*) methodSignatureForSelector: (SEL)aSelector { + const char *selTypes; const char *types; struct objc_method *mth; Class c; @@ -1607,6 +1608,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel) [NSException raise: NSInvalidArgumentException format: @"%@ null selector given", NSStringFromSelector(_cmd)]; + selTypes = sel_get_type(aSelector); c = (GSObjCIsInstance(self) ? GSObjCClass(self) : (Class)self); mth = GSGetMethod(c, aSelector, GSObjCIsInstance(self), YES); @@ -1663,6 +1665,13 @@ GSDescriptionForClassMethod(pcl self, SEL aSel) { return nil; } + else if (selTypes != 0 && GSSelectorTypesMatch(selTypes, types) == NO) + { + [NSException raise: NSInternalInconsistencyException + format: @"[%@%c%@] selector types (%s) don't match method types (%s)", + NSStringFromClass(c), (GSObjCIsInstance(self) ? '-' : '+'), + NSStringFromSelector(aSelector), selTypes, types]; + } return [NSMethodSignature signatureWithObjCTypes: types]; }