Skip to content

Commit ea67d6d

Browse files
thomasvlcopybara-github
authored andcommitted
[ObjC] Fix nullability annotations on some GPB*Dictionary types.
As announced: https://protobuf.dev/news/2025-09-19/#objc Correcting the some of the annotations as part of ObjC Major Version bump coming in 2026Q1. This is most likely to trip up Swift code calling it, but it could also impact ObjC sources depending on the annotation enforcement the files are compiled with. Fixes #22403 PiperOrigin-RevId: 815778859
1 parent 3414dc1 commit ea67d6d

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

objectivec/GPBDictionary.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ __attribute__((objc_subclassing_restricted))
913913
*
914914
* @return The object if found, nil otherwise.
915915
**/
916-
- (ObjectType)objectForKey:(uint32_t)key;
916+
- (nullable ObjectType)objectForKey:(uint32_t)key;
917917

918918
/**
919919
* Enumerates the keys and values on this dictionary with the given block.
@@ -1843,7 +1843,7 @@ __attribute__((objc_subclassing_restricted))
18431843
*
18441844
* @return The object if found, nil otherwise.
18451845
**/
1846-
- (ObjectType)objectForKey:(int32_t)key;
1846+
- (nullable ObjectType)objectForKey:(int32_t)key;
18471847

18481848
/**
18491849
* Enumerates the keys and values on this dictionary with the given block.
@@ -2773,7 +2773,7 @@ __attribute__((objc_subclassing_restricted))
27732773
*
27742774
* @return The object if found, nil otherwise.
27752775
**/
2776-
- (ObjectType)objectForKey:(uint64_t)key;
2776+
- (nullable ObjectType)objectForKey:(uint64_t)key;
27772777

27782778
/**
27792779
* Enumerates the keys and values on this dictionary with the given block.
@@ -3703,7 +3703,7 @@ __attribute__((objc_subclassing_restricted))
37033703
*
37043704
* @return The object if found, nil otherwise.
37053705
**/
3706-
- (ObjectType)objectForKey:(int64_t)key;
3706+
- (nullable ObjectType)objectForKey:(int64_t)key;
37073707

37083708
/**
37093709
* Enumerates the keys and values on this dictionary with the given block.
@@ -4633,7 +4633,7 @@ __attribute__((objc_subclassing_restricted))
46334633
*
46344634
* @return The object if found, nil otherwise.
46354635
**/
4636-
- (ObjectType)objectForKey:(BOOL)key;
4636+
- (nullable ObjectType)objectForKey:(BOOL)key;
46374637

46384638
/**
46394639
* Enumerates the keys and values on this dictionary with the given block.
@@ -5556,7 +5556,7 @@ NS_ASSUME_NONNULL_END
55565556
//% *
55575557
//% * @return The object if found, nil otherwise.
55585558
//% **/
5559-
//%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key;
5559+
//%- (nullable VALUE_TYPE)objectForKey:(KEY_TYPE)key;
55605560
//%PDDM-DEFINE VALUE_FOR_KEY_Enum(KEY_TYPE, VALUE_TYPE, VNAME)
55615561
//%VALUE_FOR_KEY_POD(KEY_TYPE, VALUE_TYPE, VNAME)
55625562
//%PDDM-DEFINE ARRAY_ARG_MODIFIERPOD()

objectivec/GPBDictionary.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream,
11791179
//
11801180

11811181
//%PDDM-DEFINE VALUE_FOR_KEY_OBJECT(KEY_TYPE, VALUE_NAME, VALUE_TYPE, KHELPER)
1182-
//%- (VALUE_TYPE)objectForKey:(KEY_TYPE)key {
1182+
//%- (nullable VALUE_TYPE)objectForKey:(KEY_TYPE)key {
11831183
//% VALUE_TYPE result = [_dictionary objectForKey:WRAPPED##KHELPER(key)];
11841184
//% return result;
11851185
//%}
@@ -1312,7 +1312,7 @@ void GPBDictionaryReadEntry(id mapDictionary, GPBCodedInputStream *stream,
13121312
//%PDDM-DEFINE BOOL_DICT_HASOBJECT(IDX, REF)
13131313
//%REF##_values[IDX] != nil
13141314
//%PDDM-DEFINE BOOL_VALUE_FOR_KEY_OBJECT(VALUE_NAME, VALUE_TYPE)
1315-
//%- (VALUE_TYPE)objectForKey:(BOOL)key {
1315+
//%- (nullable VALUE_TYPE)objectForKey:(BOOL)key {
13161316
//% return _values[key ? 1 : 0];
13171317
//%}
13181318
//%PDDM-DEFINE BOOL_SET_GPBVALUE_FOR_KEY_OBJECT(VALUE_NAME, VALUE_TYPE, VisP)
@@ -3063,7 +3063,7 @@ - (void)enumerateForTextFormat:(void (NS_NOESCAPE ^)(id keyObj, id valueObj))blo
30633063
}];
30643064
}
30653065

3066-
- (id)objectForKey:(uint32_t)key {
3066+
- (nullable id)objectForKey:(uint32_t)key {
30673067
id result = [_dictionary objectForKey:@(key)];
30683068
return result;
30693069
}
@@ -4794,7 +4794,7 @@ - (void)enumerateForTextFormat:(void (NS_NOESCAPE ^)(id keyObj, id valueObj))blo
47944794
}];
47954795
}
47964796

4797-
- (id)objectForKey:(int32_t)key {
4797+
- (nullable id)objectForKey:(int32_t)key {
47984798
id result = [_dictionary objectForKey:@(key)];
47994799
return result;
48004800
}
@@ -6525,7 +6525,7 @@ - (void)enumerateForTextFormat:(void (NS_NOESCAPE ^)(id keyObj, id valueObj))blo
65256525
}];
65266526
}
65276527

6528-
- (id)objectForKey:(uint64_t)key {
6528+
- (nullable id)objectForKey:(uint64_t)key {
65296529
id result = [_dictionary objectForKey:@(key)];
65306530
return result;
65316531
}
@@ -8256,7 +8256,7 @@ - (void)enumerateForTextFormat:(void (NS_NOESCAPE ^)(id keyObj, id valueObj))blo
82568256
}];
82578257
}
82588258

8259-
- (id)objectForKey:(int64_t)key {
8259+
- (nullable id)objectForKey:(int64_t)key {
82608260
id result = [_dictionary objectForKey:@(key)];
82618261
return result;
82628262
}
@@ -11438,7 +11438,7 @@ - (NSUInteger)count {
1143811438
return ((_values[0] != nil) ? 1 : 0) + ((_values[1] != nil) ? 1 : 0);
1143911439
}
1144011440

11441-
- (id)objectForKey:(BOOL)key {
11441+
- (nullable id)objectForKey:(BOOL)key {
1144211442
return _values[key ? 1 : 0];
1144311443
}
1144411444

0 commit comments

Comments
 (0)