Weak pointers are not implicitly annotated as nullable

Originator:m.quinones.garcia
Number:rdar://20596408 Date Originated:18/04/2015
Status:Closed Resolved:
Product:XCode Product Version:
Classification:Duplicate of 19985330 Reproducible:Always
 
Summary:
Programmer can still specify 'nonnull' annotation to a weak pointer. This is in conflict with the real behaviour of weak pointers being implicitly always nullable.

Steps to Reproduce:
Compile this code:

NS_ASSUME_NONNULL_BEGIN
 
@interface ViewController : UIViewController
 
// Note it's a weak property and compiler does not complain. 
// Anyway the property will be nullified by the runtime as it has always been. Annotations don't affect generated code.
@property (nonatomic, weak) id delegate;
 
@end
 
NS_ASSUME_NONNULL_END
 
 
// Using it:
id delegate = [[NSObject alloc] init];
ViewController *controller = [[ViewController alloc] initWithNibName:nil bundle:nil];
controller.delegate = delegate;
delegate = nil;  // controller.delegate is nil as expected. Generated code does not change.
controller.delegate = nil; // Generates warning at compile time

Expected Results:
It would be good if weak pointers are always implicitly anotated as nullable, or compiler generate a warning if programmer does not annotate as such in an annotated region.

Actual Results:
Compiler does not complain, but behaviour is correct at run time.

Version:
XCode 6.3 (6D570)

Notes:


Configuration:


Attachments:

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!