__auto_type does not inherit nullability to inferred type
Originator: | steipete | ||
Number: | rdar://33026931 | Date Originated: | 28-Jun-2017 12:03 PM |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | Xcode 9b2 |
Classification: | Other Bug | Reproducible: | Always |
Summary: When you use `__auto_type` to declare a variable, it does not inherit any nullability definitions marked by the return type of the value being assigned. Steps to Reproduce: It is easy to reproduce this with any _Nullable return type in Foundation, for example -[NSBundle pathForResource:ofType:], which is defined as such: `- (nullable NSString *)pathForResource:(nullable NSString *)name ofType:(nullable NSString *)ext;` This can easily be setup: __auto_type path = [[NSBundle mainBundle] pathForResource:@“foo” ofType:@“txt”]; Expected Results: `path` should be the type `NSString * _Nullable` because __auto_type should inherit nullability. Actual Results: `path` has the type `NSString *` and is assumed _Nonnull Version: Xcode 9b2 Notes: This can affect the use nullability warnings, since __auto_type will mark variables as assumed _Nonnull and therefore not be caught by `-Wnullable-to-nonnull-conversion` I know this has been reported before and was put off because of complexity, yet I post it again because it would *really* help to prevent bugs.
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!