From 38b9e74691b484d2521fc6d8f421fc3dc14aa143 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Fri, 27 May 2016 12:51:18 -0400 Subject: Add -Woverriding-method-mismatch. Fixes up the code to avoid some issues with isEqual: methods. Opened https://github.com/google/protobuf/issues/1616 to track the KVC collision. --- objectivec/GPBMessage.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'objectivec/GPBMessage.m') diff --git a/objectivec/GPBMessage.m b/objectivec/GPBMessage.m index 77b9dbd3..d1c5594c 100644 --- a/objectivec/GPBMessage.m +++ b/objectivec/GPBMessage.m @@ -2563,7 +2563,7 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream( #pragma mark - isEqual: & hash Support -- (BOOL)isEqual:(GPBMessage *)other { +- (BOOL)isEqual:(id)other { if (other == self) { return YES; } @@ -2572,9 +2572,10 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream( return NO; } + GPBMessage *otherMsg = other; GPBDescriptor *descriptor = [[self class] descriptor]; uint8_t *selfStorage = (uint8_t *)messageStorage_; - uint8_t *otherStorage = (uint8_t *)other->messageStorage_; + uint8_t *otherStorage = (uint8_t *)otherMsg->messageStorage_; for (GPBFieldDescriptor *field in descriptor->fields_) { if (GPBFieldIsMapOrArray(field)) { @@ -2668,14 +2669,14 @@ static void MergeRepeatedNotPackedFieldFromCodedInputStream( } // for(fields) // nil and empty are equal - if (extensionMap_.count != 0 || other->extensionMap_.count != 0) { - if (![extensionMap_ isEqual:other->extensionMap_]) { + if (extensionMap_.count != 0 || otherMsg->extensionMap_.count != 0) { + if (![extensionMap_ isEqual:otherMsg->extensionMap_]) { return NO; } } // nil and empty are equal - GPBUnknownFieldSet *otherUnknowns = other->unknownFields_; + GPBUnknownFieldSet *otherUnknowns = otherMsg->unknownFields_; if ([unknownFields_ countOfFields] != 0 || [otherUnknowns countOfFields] != 0) { if (![unknownFields_ isEqual:otherUnknowns]) { -- cgit v1.2.3