NSFastEnumeration doesn't warn about mismatched types when using Objective-C generics
| Originator: | heath.borders | ||
| Number: | rdar://25060476 | Date Originated: | 09-Mar-2016 10:38 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Version 7.2 (7C68) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
Using NSFastEnumeration with for..in syntax does not warn on generic type mismatches.
Steps to Reproduce:
Compile the following code:
NSArray<NSString *> *strings = @[@"1",
];
for (NSNumber *number in strings) {
NSLog(@"number: %@",
number);
}
NSDictionary<NSString *, NSString *> *stringsByString = @{@"1" : @"1",
};
for (NSNumber *number in stringsByString) {
NSLog(@"number: %@",
number);
}
Expected Results:
The compiler should emit warnings about both for loops because their types don’t match the generic type of the container.
Actual Results:
The compile emits no warnings.
Regression:
Notes:
Comments
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!