Objective-C parameters converted to assumed (!) variables instead of optionals (?)

Originator:kahlert
Number:rdar://18119727 Date Originated:25-Aug-2014
Status:Duplicate of 17693528 (Open) Resolved:
Product:Developer Tools Product Version:XCode6-beta6
Classification:Enhancement Reproducible:Always
 
Summary:
Parameters of Objective-C methods are converted into assumed variables, which might increase the risk of crashes significantly.
take for example the UIApplication delegate methods looks as such:
func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool

Now launchOptions is in many cases a nil value, which will crash when accessed incorrectly. In fact it cannot be "assumed" that the parameter is not nil!

I would expect methods from Cocoa to either use optional or unpacked parameters and converted Objective-C methods to always use optionals.

Same goes for return-types.
It is in fact a common use case in objective-c to return nil, which

Steps to Reproduce:
1. Write this method in an objecive-c protocol
- (NSArray*)parseWithText:(NSString*)text;
2. Add protocol to bridging header
3. Implement function in a class



Expected Results:
Func should ideally look like this:
func parseWithText(text: String?) -> [AnyObject]?


Actual Results:
func parseWithText(text: String!) -> [AnyObject]!

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!