[ObjC] mark mergeFromData:extensionRegistry: as deprecated.

Since it really isn't safe in Swift, point folks at the new api that uses errors.

PiperOrigin-RevId: 511262228
pull/11959/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent cffde99fc6
commit e3b0051109
  1. 4
      objectivec/GPBMessage.h
  2. 3
      objectivec/GPBMessage.m
  3. 6
      objectivec/Tests/GPBMessageTests.m

@ -276,7 +276,9 @@ CF_EXTERN_C_END
* unsuccessful.
**/
- (void)mergeFromData:(NSData *)data
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry;
extensionRegistry:(nullable id<GPBExtensionRegistry>)extensionRegistry
__attribute__((deprecated(
"Use -mergeFromData:extensionRegistry:error: instead, especaily if calling from Swift.")));
/**
* Parses the given data as this message's class, and merges those values into

@ -3261,7 +3261,10 @@ static void ResolveIvarSet(__unsafe_unretained GPBFieldDescriptor *field,
if (self) {
NSData *data = [aDecoder decodeObjectOfClass:[NSData class] forKey:kGPBDataCoderKey];
if (data.length) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
[self mergeFromData:data extensionRegistry:nil];
#pragma clang diagnostic pop
}
}
return self;

@ -224,7 +224,11 @@
result = [self mergeExtensionsDestination];
NSData *data = [[self mergeExtensionsSource] data];
XCTAssertNotNil(data);
[result mergeFromData:data extensionRegistry:[UnittestRoot extensionRegistry]];
NSError *error = nil;
XCTAssertTrue([result mergeFromData:data
extensionRegistry:[UnittestRoot extensionRegistry]
error:&error]);
XCTAssertNil(error);
resultData = [result data];
XCTAssertEqualObjects(resultData, mergeResultData);
XCTAssertEqualObjects(result, [self mergeExtensionsResult]);

Loading…
Cancel
Save