From a185a6ea8a5cc1d85f8a91405a0fafd007207ca4 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Fri, 27 Jan 2023 15:19:53 -0800 Subject: [PATCH] [ObjC] Mark classes that shouldn't be subclassed as such. Several of the classes vended by the runtime don't really support subclassing, so mark them as such to get compiler enforcement just in case. PiperOrigin-RevId: 505221732 --- objectivec/GPBArray.h | 10 ++++++ objectivec/GPBCodedInputStream.h | 1 + objectivec/GPBCodedOutputStream.h | 1 + objectivec/GPBDescriptor.h | 10 ++++-- objectivec/GPBDictionary.h | 55 +++++++++++++++++++++++++++++++ objectivec/GPBExtensionRegistry.h | 3 +- objectivec/GPBUnknownField.h | 3 +- objectivec/GPBUnknownFieldSet.h | 3 +- 8 files changed, 81 insertions(+), 5 deletions(-) diff --git a/objectivec/GPBArray.h b/objectivec/GPBArray.h index 4985dbe402..dc58662664 100644 --- a/objectivec/GPBArray.h +++ b/objectivec/GPBArray.h @@ -48,6 +48,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt32Array : NSObject /** The number of elements contained in the array. */ @@ -222,6 +223,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt32Array : NSObject /** The number of elements contained in the array. */ @@ -396,6 +398,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt64Array : NSObject /** The number of elements contained in the array. */ @@ -570,6 +573,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt64Array : NSObject /** The number of elements contained in the array. */ @@ -744,6 +748,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBFloatArray : NSObject /** The number of elements contained in the array. */ @@ -918,6 +923,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBDoubleArray : NSObject /** The number of elements contained in the array. */ @@ -1092,6 +1098,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBBoolArray : NSObject /** The number of elements contained in the array. */ @@ -1266,6 +1273,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBEnumArray : NSObject /** The number of elements contained in the array. */ @@ -1583,6 +1591,7 @@ NS_ASSUME_NONNULL_END //% * //% * @note This class is not meant to be subclassed. //% **/ +//%__attribute__((objc_subclassing_restricted)) //%@interface GPB##NAME##Array : NSObject //% //%/** The number of elements contained in the array. */ @@ -1675,6 +1684,7 @@ NS_ASSUME_NONNULL_END //% * //% * @note This class is not meant to be subclassed. //% **/ +//%__attribute__((objc_subclassing_restricted)) //%@interface GPB##NAME##Array : NSObject //% //%/** The number of elements contained in the array. */ diff --git a/objectivec/GPBCodedInputStream.h b/objectivec/GPBCodedInputStream.h index cbfaaf1cf0..355c9db76a 100644 --- a/objectivec/GPBCodedInputStream.h +++ b/objectivec/GPBCodedInputStream.h @@ -83,6 +83,7 @@ CF_EXTERN_C_END * * @note Subclassing of @c GPBCodedInputStream is NOT supported. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBCodedInputStream : NSObject /** diff --git a/objectivec/GPBCodedOutputStream.h b/objectivec/GPBCodedOutputStream.h index 304a24ef52..42eac77044 100644 --- a/objectivec/GPBCodedOutputStream.h +++ b/objectivec/GPBCodedOutputStream.h @@ -63,6 +63,7 @@ extern NSString *const GPBCodedOutputStreamException_WriteFailed; * * @note Subclassing of GPBCodedOutputStream is NOT supported. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBCodedOutputStream : NSObject /** diff --git a/objectivec/GPBDescriptor.h b/objectivec/GPBDescriptor.h index 8baa2306f4..034f2d4af0 100644 --- a/objectivec/GPBDescriptor.h +++ b/objectivec/GPBDescriptor.h @@ -62,7 +62,8 @@ typedef NS_ENUM(uint8_t, GPBFieldType) { /** * Describes a proto message. **/ -@interface GPBDescriptor : NSObject +__attribute__((objc_subclassing_restricted)) +@interface GPBDescriptor : NSObject - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; @@ -124,6 +125,7 @@ typedef NS_ENUM(uint8_t, GPBFieldType) { /** * Describes a proto file. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBFileDescriptor : NSObject - (instancetype)init NS_UNAVAILABLE; @@ -149,6 +151,7 @@ typedef NS_ENUM(uint8_t, GPBFieldType) { /** * Describes a oneof field. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBOneofDescriptor : NSObject - (instancetype)init NS_UNAVAILABLE; @@ -182,6 +185,7 @@ typedef NS_ENUM(uint8_t, GPBFieldType) { /** * Describes a proto field. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBFieldDescriptor : NSObject - (instancetype)init NS_UNAVAILABLE; @@ -234,6 +238,7 @@ typedef NS_ENUM(uint8_t, GPBFieldType) { /** * Describes a proto enum. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBEnumDescriptor : NSObject - (instancetype)init NS_UNAVAILABLE; @@ -329,7 +334,8 @@ typedef NS_ENUM(uint8_t, GPBFieldType) { /** * Describes a proto extension. **/ -@interface GPBExtensionDescriptor : NSObject +__attribute__((objc_subclassing_restricted)) +@interface GPBExtensionDescriptor : NSObject - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; diff --git a/objectivec/GPBDictionary.h b/objectivec/GPBDictionary.h index 90440e3f41..0e7622b8b8 100644 --- a/objectivec/GPBDictionary.h +++ b/objectivec/GPBDictionary.h @@ -57,6 +57,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt32UInt32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -152,6 +153,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt32Int32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -247,6 +249,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt32UInt64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -342,6 +345,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt32Int64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -437,6 +441,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt32BoolDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -532,6 +537,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt32FloatDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -627,6 +633,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt32DoubleDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -722,6 +729,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt32EnumDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -884,6 +892,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject /** Number of entries stored in this dictionary. */ @@ -978,6 +987,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt32UInt32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -1073,6 +1083,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt32Int32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -1168,6 +1179,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt32UInt64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -1263,6 +1275,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt32Int64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -1358,6 +1371,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt32BoolDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -1453,6 +1467,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt32FloatDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -1548,6 +1563,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt32DoubleDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -1643,6 +1659,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt32EnumDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -1805,6 +1822,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject /** Number of entries stored in this dictionary. */ @@ -1899,6 +1917,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt64UInt32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -1994,6 +2013,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt64Int32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -2089,6 +2109,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt64UInt64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -2184,6 +2205,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt64Int64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -2279,6 +2301,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt64BoolDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -2374,6 +2397,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt64FloatDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -2469,6 +2493,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt64DoubleDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -2564,6 +2589,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt64EnumDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -2726,6 +2752,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject /** Number of entries stored in this dictionary. */ @@ -2820,6 +2847,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt64UInt32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -2915,6 +2943,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt64Int32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -3010,6 +3039,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt64UInt64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -3105,6 +3135,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt64Int64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -3200,6 +3231,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt64BoolDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -3295,6 +3327,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt64FloatDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -3390,6 +3423,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt64DoubleDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -3485,6 +3519,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt64EnumDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -3647,6 +3682,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject /** Number of entries stored in this dictionary. */ @@ -3741,6 +3777,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBBoolUInt32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -3836,6 +3873,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBBoolInt32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -3931,6 +3969,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBBoolUInt64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -4026,6 +4065,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBBoolInt64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -4121,6 +4161,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBBoolBoolDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -4216,6 +4257,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBBoolFloatDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -4311,6 +4353,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBBoolDoubleDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -4406,6 +4449,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBBoolEnumDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -4568,6 +4612,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject /** Number of entries stored in this dictionary. */ @@ -4662,6 +4707,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBStringUInt32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -4757,6 +4803,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBStringInt32Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -4852,6 +4899,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBStringUInt64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -4947,6 +4995,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBStringInt64Dictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -5042,6 +5091,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBStringBoolDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -5137,6 +5187,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBStringFloatDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -5232,6 +5283,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBStringDoubleDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -5327,6 +5379,7 @@ NS_ASSUME_NONNULL_BEGIN * * @note This class is not meant to be subclassed. **/ +__attribute__((objc_subclassing_restricted)) @interface GPBStringEnumDictionary : NSObject /** Number of entries stored in this dictionary. */ @@ -5550,6 +5603,7 @@ NS_ASSUME_NONNULL_END //% * //% * @note This class is not meant to be subclassed. //% **/ +//%__attribute__((objc_subclassing_restricted)) //%@interface DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) : NSObject //% //%/** Number of entries stored in this dictionary. */ @@ -5612,6 +5666,7 @@ NS_ASSUME_NONNULL_END //% * //% * @note This class is not meant to be subclassed. //% **/ +//%__attribute__((objc_subclassing_restricted)) //%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject //% //%/** Number of entries stored in this dictionary. */ diff --git a/objectivec/GPBExtensionRegistry.h b/objectivec/GPBExtensionRegistry.h index 2c1270b19f..96f1f2e989 100644 --- a/objectivec/GPBExtensionRegistry.h +++ b/objectivec/GPBExtensionRegistry.h @@ -72,7 +72,8 @@ NS_ASSUME_NONNULL_BEGIN * MyMessage *msg = [MyMessage parseData:data extensionRegistry:registry error:&parseError]; * ``` **/ -@interface GPBExtensionRegistry : NSObject +__attribute__((objc_subclassing_restricted)) +@interface GPBExtensionRegistry : NSObject /** * Adds the given GPBExtensionDescriptor to this registry. diff --git a/objectivec/GPBUnknownField.h b/objectivec/GPBUnknownField.h index a188990cf4..b2644b39cd 100644 --- a/objectivec/GPBUnknownField.h +++ b/objectivec/GPBUnknownField.h @@ -40,7 +40,8 @@ NS_ASSUME_NONNULL_BEGIN * Store an unknown field. These are used in conjunction with * GPBUnknownFieldSet. **/ -@interface GPBUnknownField : NSObject +__attribute__((objc_subclassing_restricted)) +@interface GPBUnknownField : NSObject /** Initialize a field with the given number. */ - (instancetype)initWithNumber:(int32_t)number; diff --git a/objectivec/GPBUnknownFieldSet.h b/objectivec/GPBUnknownFieldSet.h index 5901f187bc..8837f4cb49 100644 --- a/objectivec/GPBUnknownFieldSet.h +++ b/objectivec/GPBUnknownFieldSet.h @@ -39,7 +39,8 @@ NS_ASSUME_NONNULL_BEGIN * of a message that are unknown end up in an instance of this set. This only * applies for files declared with the "proto2" syntax. **/ -@interface GPBUnknownFieldSet : NSObject +__attribute__((objc_subclassing_restricted)) +@interface GPBUnknownFieldSet : NSObject /** * Tests to see if the given field number has a value.