Nullability annotation does not check for indirect nil values

Originator:m.quinones.garcia
Number:rdar://20596086 Date Originated:18/04/2015
Status:Closed Resolved:Duplicate
Product:XCode Product Version:XCode 6.3
Classification: Reproducible:
 
Summary:
Setting a 'nil' to a nonnull property in an object generates an expected warning when compiling the code.

When setting an indirect, possibly nil pointer, compiler does not generate warnings.

Steps to Reproduce:
Compile the following Objective-C code with Xcode 6.3:

// Your object
 
NS_ASSUME_NONNULL_BEGIN
 
@interface ViewController : UIViewController
@property (nonatomic, copy) NSString *nonNullString;
@end
 
NS_ASSUME_NONNULL_END
 
// Then you use it as:
NSString *aString = @"hello";
aString = nil;
controller.nonNullString = aString;
controller.nonNullString = nil;

Expected Results:
It would be nice to have a more 'pedantic' warning when setting a value that has not been audited as nonnull like in the case above. So the programmer can't mistake by accident.

Actual Results:
Compiler accepts code and at runtime a non null value will be set to a nonnull-annotated property.

Version:
XCode 6.3 (6D570)

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!