diff options
-rw-r--r-- | lib/Edit/RewriteObjCFoundationAPI.cpp | 8 | ||||
-rw-r--r-- | test/ARCMT/objcmt-subscripting-literals-in-arc.m | 26 | ||||
-rw-r--r-- | test/ARCMT/objcmt-subscripting-literals-in-arc.m.result | 26 | ||||
-rw-r--r-- | test/ARCMT/objcmt-subscripting-literals.m | 26 | ||||
-rw-r--r-- | test/ARCMT/objcmt-subscripting-literals.m.result | 26 |
5 files changed, 80 insertions, 32 deletions
diff --git a/lib/Edit/RewriteObjCFoundationAPI.cpp b/lib/Edit/RewriteObjCFoundationAPI.cpp index 465f18051a..feecc70ec1 100644 --- a/lib/Edit/RewriteObjCFoundationAPI.cpp +++ b/lib/Edit/RewriteObjCFoundationAPI.cpp @@ -128,7 +128,7 @@ static bool rewriteToArraySubscriptGet(const ObjCInterfaceDecl *IFace, const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit) { - if (!IFace->getInstanceMethod(NS.getObjectAtIndexedSubscriptSelector())) + if (!IFace->lookupInstanceMethod(NS.getObjectAtIndexedSubscriptSelector())) return false; return rewriteToSubscriptGetCommon(Msg, commit); } @@ -137,7 +137,7 @@ static bool rewriteToDictionarySubscriptGet(const ObjCInterfaceDecl *IFace, const ObjCMessageExpr *Msg, const NSAPI &NS, Commit &commit) { - if (!IFace->getInstanceMethod(NS.getObjectForKeyedSubscriptSelector())) + if (!IFace->lookupInstanceMethod(NS.getObjectForKeyedSubscriptSelector())) return false; return rewriteToSubscriptGetCommon(Msg, commit); } @@ -151,7 +151,7 @@ static bool rewriteToArraySubscriptSet(const ObjCInterfaceDecl *IFace, const Expr *Rec = Msg->getInstanceReceiver(); if (!Rec) return false; - if (!IFace->getInstanceMethod(NS.getSetObjectAtIndexedSubscriptSelector())) + if (!IFace->lookupInstanceMethod(NS.getSetObjectAtIndexedSubscriptSelector())) return false; SourceRange MsgRange = Msg->getSourceRange(); @@ -183,7 +183,7 @@ static bool rewriteToDictionarySubscriptSet(const ObjCInterfaceDecl *IFace, const Expr *Rec = Msg->getInstanceReceiver(); if (!Rec) return false; - if (!IFace->getInstanceMethod(NS.getSetObjectForKeyedSubscriptSelector())) + if (!IFace->lookupInstanceMethod(NS.getSetObjectForKeyedSubscriptSelector())) return false; SourceRange MsgRange = Msg->getSourceRange(); diff --git a/test/ARCMT/objcmt-subscripting-literals-in-arc.m b/test/ARCMT/objcmt-subscripting-literals-in-arc.m index fd100ca94d..4d941626c0 100644 --- a/test/ARCMT/objcmt-subscripting-literals-in-arc.m +++ b/test/ARCMT/objcmt-subscripting-literals-in-arc.m @@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef; + (id)alloc; @end +@protocol NSCopying +@end + @interface NSString : NSObject + (id)stringWithString:(NSString *)string; - (id)initWithString:(NSString *)aString; @@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef; @interface NSArray : NSObject - (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; @end @interface NSArray (NSArrayCreation) @@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef; - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; - (id)initWithObjects:(id)firstObj, ...; - (id)initWithArray:(NSArray *)array; - -- (id)objectAtIndex:(unsigned long)index; @end @interface NSMutableArray : NSArray - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -- (void)setObject:(id)object atIndexedSubscript:(int)index; +@end + +@interface NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; @end @interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) - (id)objectForKeyedSubscript:(id)key; @end @@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef; - (id)initWithObjectsAndKeys:(id)firstObject, ...; - (id)initWithDictionary:(NSDictionary *)otherDictionary; - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; @end @interface NSMutableDictionary : NSDictionary - (void)setObject:(id)anObject forKey:(id)aKey; -- (void)setObject:(id)object forKeyedSubscript:(id)key; +@end + +@interface NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; @end @interface NSNumber : NSObject diff --git a/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result b/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result index 4a65a23442..6f7a723bc4 100644 --- a/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result +++ b/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result @@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef; + (id)alloc; @end +@protocol NSCopying +@end + @interface NSString : NSObject + (id)stringWithString:(NSString *)string; - (id)initWithString:(NSString *)aString; @@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef; @interface NSArray : NSObject - (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; @end @interface NSArray (NSArrayCreation) @@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef; - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; - (id)initWithObjects:(id)firstObj, ...; - (id)initWithArray:(NSArray *)array; - -- (id)objectAtIndex:(unsigned long)index; @end @interface NSMutableArray : NSArray - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -- (void)setObject:(id)object atIndexedSubscript:(int)index; +@end + +@interface NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; @end @interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) - (id)objectForKeyedSubscript:(id)key; @end @@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef; - (id)initWithObjectsAndKeys:(id)firstObject, ...; - (id)initWithDictionary:(NSDictionary *)otherDictionary; - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; @end @interface NSMutableDictionary : NSDictionary - (void)setObject:(id)anObject forKey:(id)aKey; -- (void)setObject:(id)object forKeyedSubscript:(id)key; +@end + +@interface NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; @end @interface NSNumber : NSObject diff --git a/test/ARCMT/objcmt-subscripting-literals.m b/test/ARCMT/objcmt-subscripting-literals.m index 6d626c4683..e9ed788275 100644 --- a/test/ARCMT/objcmt-subscripting-literals.m +++ b/test/ARCMT/objcmt-subscripting-literals.m @@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef; + (id)alloc; @end +@protocol NSCopying +@end + @interface NSString : NSObject + (id)stringWithString:(NSString *)string; - (id)initWithString:(NSString *)aString; @@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef; @interface NSArray : NSObject - (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; @end @interface NSArray (NSArrayCreation) @@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef; - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; - (id)initWithObjects:(id)firstObj, ...; - (id)initWithArray:(NSArray *)array; - -- (id)objectAtIndex:(unsigned long)index; @end @interface NSMutableArray : NSArray - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -- (void)setObject:(id)object atIndexedSubscript:(int)index; +@end + +@interface NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; @end @interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) - (id)objectForKeyedSubscript:(id)key; @end @@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef; - (id)initWithObjectsAndKeys:(id)firstObject, ...; - (id)initWithDictionary:(NSDictionary *)otherDictionary; - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; @end @interface NSMutableDictionary : NSDictionary - (void)setObject:(id)anObject forKey:(id)aKey; -- (void)setObject:(id)object forKeyedSubscript:(id)key; +@end + +@interface NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; @end @interface NSNumber : NSObject diff --git a/test/ARCMT/objcmt-subscripting-literals.m.result b/test/ARCMT/objcmt-subscripting-literals.m.result index a4eca6a447..4e49c5e344 100644 --- a/test/ARCMT/objcmt-subscripting-literals.m.result +++ b/test/ARCMT/objcmt-subscripting-literals.m.result @@ -12,6 +12,9 @@ typedef const struct __CFString * CFStringRef; + (id)alloc; @end +@protocol NSCopying +@end + @interface NSString : NSObject + (id)stringWithString:(NSString *)string; - (id)initWithString:(NSString *)aString; @@ -19,7 +22,10 @@ typedef const struct __CFString * CFStringRef; @interface NSArray : NSObject - (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; @end @interface NSArray (NSArrayCreation) @@ -32,16 +38,21 @@ typedef const struct __CFString * CFStringRef; - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; - (id)initWithObjects:(id)firstObj, ...; - (id)initWithArray:(NSArray *)array; - -- (id)objectAtIndex:(unsigned long)index; @end @interface NSMutableArray : NSArray - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -- (void)setObject:(id)object atIndexedSubscript:(int)index; +@end + +@interface NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; @end @interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) - (id)objectForKeyedSubscript:(id)key; @end @@ -57,13 +68,14 @@ typedef const struct __CFString * CFStringRef; - (id)initWithObjectsAndKeys:(id)firstObject, ...; - (id)initWithDictionary:(NSDictionary *)otherDictionary; - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; @end @interface NSMutableDictionary : NSDictionary - (void)setObject:(id)anObject forKey:(id)aKey; -- (void)setObject:(id)object forKeyedSubscript:(id)key; +@end + +@interface NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; @end @interface NSNumber : NSObject |