Xcode 7.0: Allow self to be redefined in guard expression to strongify weak reference

Originator:david.w.hart
Number:rdar://22716448 Date Originated:16-Sep-2015 09:55 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode 7.0 (7A218)
Classification:Enhancement Reproducible:Always
 
Currently, when defining a closure with weak self, I do something like this:

closureFunction { [weak self] in
    guard let sself = self else { return }
    sself.property = 5
    sself.otherFunction()
}

I do the above to avoid the more ugly and error prone:

closureFunction { [weak self] in
    self?.property = 5
    self?.otherFunction()
}

Could it be possible to do the following:

closureFunction { [weak self] in
    guard let self = self else { return }
    self.property = 5
    self.otherFunction()
}

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!