From 92af2688ec7050d5c4efc9f7a862034c655c1135 Mon Sep 17 00:00:00 2001 From: Frederik Seiffert Date: Sat, 21 Dec 2019 16:37:06 +0100 Subject: [PATCH] Fixed generics declarations for collection subclasses. Generics declarations of NSMutableArray, NSMutableDictionary, NSMutableOrderedSet, and NSMutableSet were not being passed up to superclass. This meant that calling generic methods declared in the superclass on a subclass object were not recognized by the compiler to return a declared generic object type. All protocol declarations that are being replaced with generics declarations are already declared by the respective superclass, and thus the list of implemented protocols does not change. Also removed unecessary protocol declarations on NSMutableIndexSet to match the other collection subclasses. Also added missing generics declaration to NSCountedSet (subclass of NSMutableSet). --- include/Foundation/NSCountedSet.h | 4 ++-- include/Foundation/NSMutableArray.h | 2 +- include/Foundation/NSMutableDictionary.h | 2 +- include/Foundation/NSMutableIndexSet.h | 2 +- include/Foundation/NSMutableOrderedSet.h | 2 +- include/Foundation/NSMutableSet.h | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/include/Foundation/NSCountedSet.h b/include/Foundation/NSCountedSet.h index 092b7da909..94391a936a 100644 --- a/include/Foundation/NSCountedSet.h +++ b/include/Foundation/NSCountedSet.h @@ -26,6 +26,6 @@ @class NSEnumerator; FOUNDATION_EXPORT_CLASS -@interface NSCountedSet : NSMutableSet -- (NSUInteger)countForObject:(id)anObject; +@interface NSCountedSet : NSMutableSet +- (NSUInteger)countForObject:(ObjectType)anObject; @end diff --git a/include/Foundation/NSMutableArray.h b/include/Foundation/NSMutableArray.h index 7e979d3578..e1e75000cd 100644 --- a/include/Foundation/NSMutableArray.h +++ b/include/Foundation/NSMutableArray.h @@ -28,7 +28,7 @@ @class NSSortDescriptor; FOUNDATION_EXPORT_CLASS -@interface NSMutableArray : NSArray +@interface NSMutableArray : NSArray + (instancetype)arrayWithCapacity:(NSUInteger)numItems; - (instancetype)initWithCapacity:(NSUInteger)numItems; - (void)addObject:(ObjectType)anObject; diff --git a/include/Foundation/NSMutableDictionary.h b/include/Foundation/NSMutableDictionary.h index f09589af29..7d6fc56e64 100644 --- a/include/Foundation/NSMutableDictionary.h +++ b/include/Foundation/NSMutableDictionary.h @@ -25,7 +25,7 @@ @class NSArray; FOUNDATION_EXPORT_CLASS -@interface NSMutableDictionary : NSDictionary +@interface NSMutableDictionary : NSDictionary + (instancetype)dictionaryWithCapacity:(NSUInteger)numItems; - (instancetype)initWithCapacity:(NSUInteger)numItems; + (NSMutableDictionary*)dictionaryWithSharedKeySet:(id)keyset; diff --git a/include/Foundation/NSMutableIndexSet.h b/include/Foundation/NSMutableIndexSet.h index 4ed325a793..d52cf6593d 100644 --- a/include/Foundation/NSMutableIndexSet.h +++ b/include/Foundation/NSMutableIndexSet.h @@ -21,7 +21,7 @@ #import FOUNDATION_EXPORT_CLASS -@interface NSMutableIndexSet : NSIndexSet +@interface NSMutableIndexSet : NSIndexSet - (void)addIndex:(NSUInteger)index; - (void)addIndexes:(NSIndexSet*)indexSet; - (void)addIndexesInRange:(NSRange)indexRange; diff --git a/include/Foundation/NSMutableOrderedSet.h b/include/Foundation/NSMutableOrderedSet.h index d84655498d..a728e0c9ab 100644 --- a/include/Foundation/NSMutableOrderedSet.h +++ b/include/Foundation/NSMutableOrderedSet.h @@ -26,7 +26,7 @@ @class NSSet; FOUNDATION_EXPORT_CLASS -@interface NSMutableOrderedSet : NSOrderedSet +@interface NSMutableOrderedSet : NSOrderedSet +(instancetype)orderedSetWithCapacity : (NSUInteger)numItems STUB_METHOD; - (instancetype)initWithCapacity:(NSUInteger)numItems STUB_METHOD; - (instancetype)init; diff --git a/include/Foundation/NSMutableSet.h b/include/Foundation/NSMutableSet.h index 298a48dee7..44fdae458c 100644 --- a/include/Foundation/NSMutableSet.h +++ b/include/Foundation/NSMutableSet.h @@ -25,7 +25,7 @@ @class NSArray; FOUNDATION_EXPORT_CLASS -@interface NSMutableSet : NSSet +@interface NSMutableSet : NSSet + (instancetype)setWithCapacity:(NSUInteger)numItems; - (instancetype)initWithCapacity:(NSUInteger)numItems; - (void)addObject:(ObjectType)object;