@nonobjc methods in extension of generic Swift class conforming to objc protocol segfaults
| Originator: | Pasan.pr | ||
| Number: | rdar://27383752 | Date Originated: | 07/15/2016 |
| Status: | Open | Resolved: | |
| Product: | Product Version: | ||
| Classification: | Reproducible: | Always |
When implementing an optional method of an ObjC protocol in an extension of a generic Swift class and annotating with @nonobjc, the compiler segfaults.
If the optional protocol method is implemented in the class declaration and not the extension, no segfault occurs with or without the @nonobjc attribute.
If the method being implemented is not an optional method of an ObjC protocol, a compiler warning is provided "Non @objc method.....does not satisfy requirement of @objc protocol" along with "@objc is not supported with extensions of generic classes".
Steps to reproduce:
import Foundation
import CoreData
// Does not segfault
class Foo<T>: NSObject, NSFetchedResultsControllerDelegate {
override init() {
super.init()
}
@nonobjc func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
}
}
// Segfaults
class Bar<T>: NSObject {
override init() {
super.init()
}
}
extension Bar: NSFetchedResultsControllerDelegate {
@nonobjc func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
}
}
Expected Results:
Meaningful compiler error
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!