[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
diff --git a/objectivec/GPBArray.h b/objectivec/GPBArray.h
index 4985dbe..dc58662 100644
--- a/objectivec/GPBArray.h
+++ b/objectivec/GPBArray.h
@@ -48,6 +48,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt32Array : NSObject <NSCopying>
 
 /** The number of elements contained in the array. */
@@ -222,6 +223,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt32Array : NSObject <NSCopying>
 
 /** The number of elements contained in the array. */
@@ -396,6 +398,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt64Array : NSObject <NSCopying>
 
 /** The number of elements contained in the array. */
@@ -570,6 +573,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt64Array : NSObject <NSCopying>
 
 /** The number of elements contained in the array. */
@@ -744,6 +748,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBFloatArray : NSObject <NSCopying>
 
 /** The number of elements contained in the array. */
@@ -918,6 +923,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBDoubleArray : NSObject <NSCopying>
 
 /** The number of elements contained in the array. */
@@ -1092,6 +1098,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBBoolArray : NSObject <NSCopying>
 
 /** The number of elements contained in the array. */
@@ -1266,6 +1273,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBEnumArray : NSObject <NSCopying>
 
 /** The number of elements contained in the array. */
@@ -1583,6 +1591,7 @@
 //% *
 //% * @note This class is not meant to be subclassed.
 //% **/
+//%__attribute__((objc_subclassing_restricted))
 //%@interface GPB##NAME##Array : NSObject <NSCopying>
 //%
 //%/** The number of elements contained in the array. */
@@ -1675,6 +1684,7 @@
 //% *
 //% * @note This class is not meant to be subclassed.
 //% **/
+//%__attribute__((objc_subclassing_restricted))
 //%@interface GPB##NAME##Array : NSObject <NSCopying>
 //%
 //%/** The number of elements contained in the array. */
diff --git a/objectivec/GPBCodedInputStream.h b/objectivec/GPBCodedInputStream.h
index cbfaaf1..355c9db 100644
--- a/objectivec/GPBCodedInputStream.h
+++ b/objectivec/GPBCodedInputStream.h
@@ -83,6 +83,7 @@
  *
  * @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 304a24e..42eac77 100644
--- a/objectivec/GPBCodedOutputStream.h
+++ b/objectivec/GPBCodedOutputStream.h
@@ -63,6 +63,7 @@
  *
  * @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 8baa230..034f2d4 100644
--- a/objectivec/GPBDescriptor.h
+++ b/objectivec/GPBDescriptor.h
@@ -62,7 +62,8 @@
 /**
  * Describes a proto message.
  **/
-@interface GPBDescriptor : NSObject <NSCopying>
+__attribute__((objc_subclassing_restricted))
+@interface GPBDescriptor : NSObject<NSCopying>
 
 - (instancetype)init NS_UNAVAILABLE;
 + (instancetype)new NS_UNAVAILABLE;
@@ -124,6 +125,7 @@
 /**
  * Describes a proto file.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBFileDescriptor : NSObject
 
 - (instancetype)init NS_UNAVAILABLE;
@@ -149,6 +151,7 @@
 /**
  * Describes a oneof field.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBOneofDescriptor : NSObject
 
 - (instancetype)init NS_UNAVAILABLE;
@@ -182,6 +185,7 @@
 /**
  * Describes a proto field.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBFieldDescriptor : NSObject
 
 - (instancetype)init NS_UNAVAILABLE;
@@ -234,6 +238,7 @@
 /**
  * Describes a proto enum.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBEnumDescriptor : NSObject
 
 - (instancetype)init NS_UNAVAILABLE;
@@ -329,7 +334,8 @@
 /**
  * Describes a proto extension.
  **/
-@interface GPBExtensionDescriptor : NSObject <NSCopying>
+__attribute__((objc_subclassing_restricted))
+@interface GPBExtensionDescriptor : NSObject<NSCopying>
 
 - (instancetype)init NS_UNAVAILABLE;
 + (instancetype)new NS_UNAVAILABLE;
diff --git a/objectivec/GPBDictionary.h b/objectivec/GPBDictionary.h
index 90440e3..0e7622b 100644
--- a/objectivec/GPBDictionary.h
+++ b/objectivec/GPBDictionary.h
@@ -57,6 +57,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt32UInt32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -152,6 +153,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt32Int32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -247,6 +249,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt32UInt64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -342,6 +345,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt32Int64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -437,6 +441,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt32BoolDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -532,6 +537,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt32FloatDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -627,6 +633,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt32DoubleDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -722,6 +729,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt32EnumDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -884,6 +892,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -978,6 +987,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt32UInt32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -1073,6 +1083,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt32Int32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -1168,6 +1179,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt32UInt64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -1263,6 +1275,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt32Int64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -1358,6 +1371,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt32BoolDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -1453,6 +1467,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt32FloatDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -1548,6 +1563,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt32DoubleDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -1643,6 +1659,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt32EnumDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -1805,6 +1822,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt32ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -1899,6 +1917,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt64UInt32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -1994,6 +2013,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt64Int32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -2089,6 +2109,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt64UInt64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -2184,6 +2205,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt64Int64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -2279,6 +2301,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt64BoolDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -2374,6 +2397,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt64FloatDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -2469,6 +2493,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt64DoubleDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -2564,6 +2589,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt64EnumDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -2726,6 +2752,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBUInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -2820,6 +2847,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt64UInt32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -2915,6 +2943,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt64Int32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -3010,6 +3039,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt64UInt64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -3105,6 +3135,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt64Int64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -3200,6 +3231,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt64BoolDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -3295,6 +3327,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt64FloatDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -3390,6 +3423,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt64DoubleDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -3485,6 +3519,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt64EnumDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -3647,6 +3682,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBInt64ObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -3741,6 +3777,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBBoolUInt32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -3836,6 +3873,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBBoolInt32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -3931,6 +3969,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBBoolUInt64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -4026,6 +4065,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBBoolInt64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -4121,6 +4161,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBBoolBoolDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -4216,6 +4257,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBBoolFloatDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -4311,6 +4353,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBBoolDoubleDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -4406,6 +4449,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBBoolEnumDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -4568,6 +4612,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBBoolObjectDictionary<__covariant ObjectType> : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -4662,6 +4707,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBStringUInt32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -4757,6 +4803,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBStringInt32Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -4852,6 +4899,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBStringUInt64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -4947,6 +4995,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBStringInt64Dictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -5042,6 +5091,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBStringBoolDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -5137,6 +5187,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBStringFloatDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -5232,6 +5283,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBStringDoubleDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -5327,6 +5379,7 @@
  *
  * @note This class is not meant to be subclassed.
  **/
+__attribute__((objc_subclassing_restricted))
 @interface GPBStringEnumDictionary : NSObject <NSCopying>
 
 /** Number of entries stored in this dictionary. */
@@ -5550,6 +5603,7 @@
 //% *
 //% * @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 <NSCopying>
 //%
 //%/** Number of entries stored in this dictionary. */
@@ -5612,6 +5666,7 @@
 //% *
 //% * @note This class is not meant to be subclassed.
 //% **/
+//%__attribute__((objc_subclassing_restricted))
 //%@interface GPB##KEY_NAME##VALUE_NAME##Dictionary : NSObject <NSCopying>
 //%
 //%/** Number of entries stored in this dictionary. */
diff --git a/objectivec/GPBExtensionRegistry.h b/objectivec/GPBExtensionRegistry.h
index 2c1270b..96f1f2e 100644
--- a/objectivec/GPBExtensionRegistry.h
+++ b/objectivec/GPBExtensionRegistry.h
@@ -72,7 +72,8 @@
  * MyMessage *msg = [MyMessage parseData:data extensionRegistry:registry error:&parseError];
  * ```
  **/
-@interface GPBExtensionRegistry : NSObject <NSCopying, GPBExtensionRegistry>
+__attribute__((objc_subclassing_restricted))
+@interface GPBExtensionRegistry : NSObject<NSCopying, GPBExtensionRegistry>
 
 /**
  * Adds the given GPBExtensionDescriptor to this registry.
diff --git a/objectivec/GPBUnknownField.h b/objectivec/GPBUnknownField.h
index a188990..b2644b3 100644
--- a/objectivec/GPBUnknownField.h
+++ b/objectivec/GPBUnknownField.h
@@ -40,7 +40,8 @@
  * Store an unknown field. These are used in conjunction with
  * GPBUnknownFieldSet.
  **/
-@interface GPBUnknownField : NSObject <NSCopying>
+__attribute__((objc_subclassing_restricted))
+@interface GPBUnknownField : NSObject<NSCopying>
 
 /** Initialize a field with the given number. */
 - (instancetype)initWithNumber:(int32_t)number;
diff --git a/objectivec/GPBUnknownFieldSet.h b/objectivec/GPBUnknownFieldSet.h
index 5901f18..8837f4c 100644
--- a/objectivec/GPBUnknownFieldSet.h
+++ b/objectivec/GPBUnknownFieldSet.h
@@ -39,7 +39,8 @@
  * 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 <NSCopying>
+__attribute__((objc_subclassing_restricted))
+@interface GPBUnknownFieldSet : NSObject<NSCopying>
 
 /**
  * Tests to see if the given field number has a value.