Objective-C Blocks Don't Check Parameters' Generic Types

Number:rdar://27014664 Date Originated:25-Jun-2016 02:03 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Version 8.0 beta (8S128d)
Classification:Serious Bug Reproducible:Always
If a block accepts a parameter that contains a generic type, the block may be assigned to a variable with an incompatible generic type

Steps to Reproduce:
- (void)testExample {
    void (^blockWithNSArrayOfNSStrings)(NSArray<NSString *> *stringArray) = ^(NSArray<NSNumber *> *numberArray)
        NSLog(@"numberArray: %@",
    blockWithNSArrayOfNSStrings([NSArray<NSString *> arrayWithObjects:

Expected Results:
The assignment should fail to compile because `blockWithNSArrayOfNSStrings` accepts an `NSArray` containing `NSString`s, but it’s assigned a block accepting an `NSArray` containing `NSNumber`s, and `NSNumber` is not a supertype of `NSString`.

Actual Results:
The assignment compiles without warnings from either clang or the analyzer.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!