I installed Xcode 7 GM (7A218) today, and I got an interesting warning.
Dialogue.swift:91:25: Conditional cast from 'T' to 'NSError' always succeeds
Here's my source code.
static func runErrorAlertModally<T: ErrorType>(error: T) {
func makeAlert() -> NSAlert {
if let error = error as? NSError { // Conditional cast from 'T' to 'NSError' always succeeds
return NSAlert(error: error)
}
else {
let a = NSAlert()
a.messageText = "\(error)"
return a
}
}
makeAlert().runModal()
}
AFAIK, ErrorType is just a marker type to mark a type can be thrown. But "why" and "how" `ErrorType` can be casted into `NSError` without any special treatment?