Swift extensions: Objective-C method 'A' provided by method 'A*' does not match the requirement's selector

Originator:thomas.mellenthin
Number:rdar://26892526 Date Originated:2016-06-20
Status:Closed Resolved:2016-10-04
Product:macOS SDK Product Version:10.12
Classification:Other Bug Reproducible:always
 
Summary:
I get the following error, when a swift extension is used to implement a NSFetchedResultsControllerDelegate method:

Objective-C method 'controller:didChange:at:for:newIndexPath:' provided by method 'controller(_:didChange:at:for:newIndexPath:)' does not match the requirement's selector ('controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:')

When the method is inside the main class declaration, the code compiles. When the same method is inside an extension, the compiler show the error above.

See the attached sample project (rdardemo.zip)

Steps to Reproduce:
1. Open sample project
2. compile - no errors
3. remove the comment block to put the method inside the extension - compiler error


Expected Results:
The compiler is happy, no matter where the delegate method is declared.

Actual Results:
Objective-C method 'controller:didChange:at:for:newIndexPath:' provided by method 'controller(_:didChange:at:for:newIndexPath:)' does not match the requirement's selector ('controller:didChangeObject:atIndexPath:forChangeType:newIndexPath:')

Version:
Xcode 8.0b1 / 8S128d, OSX 10.11.5 / 15F34

Notes:


Configuration:
Xcode 8.0b1, OSX 10.11.4, SDK 10.12 / iOS SDK 10



Sample code:
---------------------8<---------------------
//  rdar 26892526  demo

import Foundation
import CoreData

@available(OSX 10.12, *)
public class SomeClass : NSObject, NSFetchedResultsControllerDelegate {
    private var deviceFetcher : NSFetchedResultsController<NSFetchRequestResult>?

    /****************************  <--- remove comment block to trigger issue

}

// MARK: NSFetchedResultsControllerDelegate
@available(OSX 10.12, *)
extension SomeClass {

   **************************/
    // Error: Objective-C method 'controller:didChange:at:for:newIndexPath:' provided by method
    //                           'controller(_:didChange:at:for:newIndexPath:)' does not match the requirement's selector
    //
    // When this delegate method is in a category
    @available(OSX 10.12, *)
    public func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: AnyObject, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {
        //
    }
}




---------------------8<---------------------

Comments

Fixed with Xcode 8 b2 (8T46g)

By thomas.mellenthin at Oct. 5, 2016, 8:45 a.m. (reply...)

Feedback from Apple

We believe this issue is resolved in the latest Xcode 8.1 beta.

By thomas.mellenthin at Oct. 5, 2016, 8:08 a.m. (reply...)

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!