"Instance method nearly matches optional requirement", workaround is not working for method with an Error parameter.

Originator:ch
Number:rdar://29109640 Date Originated:04-Nov-2016 02:08 PM
Status:Open Resolved:
Product:XCode Product Version:XCode 8.1 (8B62)
Classification: Reproducible:Always
 
Summary:
Using CoreBluetooth, I would like to make a swift extension of my UIViewController compatible with the CBPeripheralDelegate protocol.

I have the following warning 'Instance method nearly matches optional requirement' for all methods having an Error type parameter.

As specified in the Swift 3 migration tool, we can make it work by adding an @objc() statement with the original objective-c selector inside. Adding it create an error telling us that Error is not compatible with NSError. Doing the conversion remove the error but does not remove the warning.

After converting, I still have the error and it seems that my delegate method is never called.

Steps to Reproduce:
1. Open XCode
2. Import CoreBluetooth.
3. Create a swift class inheriting from NSObject.
4. Create an extension to conform to the NSPeripheralProtocol
5. Implement a function that has an Error type as parameter.
6. See the warning 'Instance method nearly matches optional requirement'
7. Add the @objc() statement with the original selector inside.
8. See an error telling about type incompatibilities.
9. Convert Error? as NSError?
10. Still have the warning 'Instance method nearly matches optional requirement'

Expected Results:
1. Open XCode.
2. Import CoreBluetooth.
3. Create a swift class inheriting from NSObject.
4. Create an extension to conform to the NSPeripheralProtocol.
5. Implement a function that has an Error type as parameter.
4. Compilation should work.

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!