Xcode 7.0: Parameters to NSComparisonResult block should be _Nullable

Originator:igeek1
Number:rdar://22826174 Date Originated:23-Sep-2015 04:39 PM
Status:Closed Resolved:08-Oct-2015 10:25 PM
Product:Developer Tools Product Version:Xcode 7.0 (7A220)
Classification:Serious Bug Reproducible:Always
 
Summary:
NSComparisonResult is defined as (^NSComparator)(id obj1, id obj2), but it is within an NS_ASSUME_NONNULL_BEGIN block, so its parameters are autocompleted as non-null, but they should be nullable.

Steps to Reproduce:
1. Desire to write a sort descriptor with a custom comparator that does something special with nil values (sorts them to the end of an ascending sort, for example).
2. Type “[NSSortDescriptor sortDescriptor” and look at the autocomplete options.
3. Allow Xcode to autocomplete the method +sortDescriptorWithKey:ascending:comparator:, including the comparator block parameters.

Expected Results:
The comparator block interface completes as ^NSComparisonResult(id  _Nullable obj1, id  _Nullable obj2) {

Actual Results:
The comparator block interface completes as ^NSComparisonResult(id  _Nonnull obj1, id  _Nonnull obj2) {

Regression:
Prior to nullability annotations being available, this was not an issue, because obj1 and obj2 could implicitly be nil or not according to Objective-C conventions.

Notes:
The issue is not that the autocomplete is wrong. It’s that I think the default parameter annotations of _Nonnull are wrong, and that they should be _Nullable instead.

Comments

Message from Apple Developer Relations

Engineering has determined that this issue behaves as intended.

We are now closing this bug report.

If you just have questions about the resolution, then please update your bug report with that information so we can respond.


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!