【Swift】Compiler segfault when calling an optional closure that takes an inout parameter of generic type

Originator:wirth_caesar
Number:rdar://19138849 Date Originated:04-Dec-2014
Status:Duplicate of 18841652 (Closed) Resolved:
Product:Developer Tools Product Version:Xcode 6.1, 6.2
Classification:Crash Reproducible:Always
 
I was trying to write a function that took a closure that allowed the caller to configure an object created before it continued with its logic. I didn't want to make it a required parameter, but trying to call it without being required, the compiler would crash.

I reduced my code down to the following, which crashes in the Playground, but works when the parameter is not Optional: 

class MyType<T where T: NSObject> {
    
    func createObject(populate: ((inout T)->())?) -> T {
        var t: T = T()
        populate?(&t)
        return t
    }
    
}

Version:
Version 6.2 (6C86e), Version 6.1 (6A1052d) (tested)
Mac OS X 10.9.5 Build 13F34

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!