diff options
| author | Douglas Gregor <dgregor@apple.com> | 2015-07-07 03:58:42 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2015-07-07 03:58:42 +0000 |
| commit | ab209d83be5dadff4f17364a71f323b89e3c63f8 (patch) | |
| tree | 5e97315685c9476095deef062e53e98e525d78e5 /clang/test/SemaObjC/parameterized_classes_subst.m | |
| parent | 10dc9d80cbb47675be0c6ea8481e12ec197e1637 (diff) | |
| download | bcm5719-llvm-ab209d83be5dadff4f17364a71f323b89e3c63f8.tar.gz bcm5719-llvm-ab209d83be5dadff4f17364a71f323b89e3c63f8.zip | |
Implement the Objective-C __kindof type qualifier.
The __kindof type qualifier can be applied to Objective-C object
(pointer) types to indicate id-like behavior, which includes implicit
"downcasting" of __kindof types to subclasses and id-like message-send
behavior. __kindof types provide better type bounds for substitutions
into unspecified generic types, which preserves more type information.
llvm-svn: 241548
Diffstat (limited to 'clang/test/SemaObjC/parameterized_classes_subst.m')
| -rw-r--r-- | clang/test/SemaObjC/parameterized_classes_subst.m | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/test/SemaObjC/parameterized_classes_subst.m b/clang/test/SemaObjC/parameterized_classes_subst.m index 6804bdc7955..dc243069ca1 100644 --- a/clang/test/SemaObjC/parameterized_classes_subst.m +++ b/clang/test/SemaObjC/parameterized_classes_subst.m @@ -18,6 +18,9 @@ __attribute__((objc_root_class)) @interface NSString : NSObject <NSCopying> @end +@interface NSMutableString : NSString +@end + @interface NSNumber : NSObject <NSCopying> @end @@ -144,6 +147,7 @@ void test_message_send_result( NSMutableSet *mutSet, MutableSetOfArrays *mutArraySet, NSArray<NSString *> *stringArray, + NSArray<__kindof NSString *> *kindofStringArray, void (^block)(void)) { int *ip; ip = [stringSet firstObject]; // expected-warning{{from 'NSString *'}} @@ -171,6 +175,12 @@ void test_message_send_result( [[NSMutableArray alloc] initWithArray: stringArray]; // okay [[NSMutableArray<NSString *> alloc] initWithArray: stringArray]; // okay [[NSMutableArray<NSNumber *> alloc] initWithArray: stringArray]; // expected-warning{{sending 'NSArray<NSString *> *' to parameter of type 'NSArray<NSNumber *> *'}} + + ip = [[[NSViewController alloc] init] view]; // expected-warning{{from '__kindof NSView *'}} + [[[[NSViewController alloc] init] view] toggle]; + + NSMutableString *mutStr = kindofStringArray[0]; + NSNumber *number = kindofStringArray[0]; // expected-warning{{of type '__kindof NSString *'}} } void test_message_send_param( @@ -215,7 +225,9 @@ void test_property_read( ip = mutSet.allObjects; // expected-warning{{from 'NSArray *'}} ip = mutArraySet.allObjects; // expected-warning{{from 'NSArray *'}} - ip = mutDict.someRandomKey; // expected-warning{{from 'id'}} + ip = mutDict.someRandomKey; // expected-warning{{from '__kindof id<NSCopying>'}} + + ip = [[NSViewController alloc] init].view; // expected-warning{{from '__kindof NSView *'}} } void test_property_write( |

