Przeglądaj źródła

Tighten up class usage/checks.

- Ensure extensions resolution/wiring is happening directly on the
  messageClass (incase someone is doing odd things our out classes).
- Make the extension message check match the other class checks in
  for mergeFrom/isEqual/etc.
Thomas Van Lenten 8 lat temu
rodzic
commit
f5a01d1bbd
1 zmienionych plików z 2 dodań i 2 usunięć
  1. 2 2
      objectivec/GPBMessage.m

+ 2 - 2
objectivec/GPBMessage.m

@@ -130,7 +130,7 @@ static NSError *ErrorFromException(NSException *exception) {
 
 
 static void CheckExtension(GPBMessage *self,
 static void CheckExtension(GPBMessage *self,
                            GPBExtensionDescriptor *extension) {
                            GPBExtensionDescriptor *extension) {
-  if ([self class] != extension.containingMessageClass) {
+  if (![self isKindOfClass:extension.containingMessageClass]) {
     [NSException
     [NSException
          raise:NSInvalidArgumentException
          raise:NSInvalidArgumentException
         format:@"Extension %@ used on wrong class (%@ instead of %@)",
         format:@"Extension %@ used on wrong class (%@ instead of %@)",
@@ -3189,7 +3189,7 @@ static void ResolveIvarSet(GPBFieldDescriptor *field,
 
 
 + (BOOL)resolveClassMethod:(SEL)sel {
 + (BOOL)resolveClassMethod:(SEL)sel {
   // Extensions scoped to a Message and looked up via class methods.
   // Extensions scoped to a Message and looked up via class methods.
-  if (GPBResolveExtensionClassMethod(self, sel)) {
+  if (GPBResolveExtensionClassMethod([self descriptor].messageClass, sel)) {
     return YES;
     return YES;
   }
   }
   return [super resolveClassMethod:sel];
   return [super resolveClassMethod:sel];