NSError** without a nullability type shows as a warning which can't be suppressed

Originator:stephen.groom
Number:rdar://21766176 Date Originated:10-Jul-2015 04:05 PM
Status:Behaves correctly Resolved:15-Jul-2015 03:42 PM
Product:Developer Tools Product Version:Xcode 7.0 beta (7A121l)
Classification:Other Bug Reproducible:Always
 
When defining a method with nullability specifiers which takes a NSError** as a parameter, it shows a compiler warning stating that “Pointer is missing a nullability type specifier (__nonnull or __nullable)”.  As far as I can tell there is no way to annotate it with such a declaration.

It is my understanding based on https://developer.apple.com/swift/blog/?id=25 - “The particular type NSError ** is so often used to return errors via method parameters that it is always assumed to be a nullable pointer to a nullable NSError reference.” that this should both pointers should be assumed to be nullable.

Example:

- (void)exampleMethod:(nonnull id)aParameter error:(NSError **)error;
//Pointer is missing a nullability type specifier (__nonnull or __nullable)

Change this to:

- (void)exampleMethod:(nonnull id)aParameter error:(nullable NSError **)error
//Pointer is missing a nullability type specifier (__nonnull or __nullable)
//Nullability keyword 'nullable' cannot be applied to multi-level pointer type 'NSError *__autoreleasing *' (fix it?)

Tapping fix it generates

- (void)exampleMethod:(nonnull id)aParameter error:(__nullable NSError **)error; 
//Pointer is missing a nullability type specifier (__nonnull or __nullable)

It should be possible to annotate both pointers in a double pointer.
The NSError** type specifically could be made to be assumed nullable

Comments

Apple Developer Relations

Engineering has determined that this issue behaves as intended based on the following information:

The compiler is behaving correctly. The correct spelling for this case is

NSError * __nullable * __nullable

Both “__nullable”s will be inferred when the code is wrapped in an audit region with NS_ASSUME_NONNULL_BEGIN/NS_ASSUME_NONNULL_END.

By stephen.groom at July 16, 2015, 4:17 p.m. (reply...)

Breaks NSError transformation from Swift?

I can't get a 2 arity Objective-C method with an annotated last argument (NSError * __nullable * __nullable) to be callable from Swift as try Foo.bar("first arg").

I get the error:

Cannot convert value of type 'String' to expected argument type '(String, error: NSErrorPointer)' (aka '(String, error: AutoreleasingUnsafeMutablePointer<Optional<NSError>>)')

Do nullability annotations turn off the automatic do..try..catch conversion?

EDIT: My problem turned out to be the setting of the return type of my class method to nonnull instead of nullable


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!