It is better to inherit NSObjectProtocol from Equatable and Hashable than extend NSObject to conform to them

Originator:an00na
Number:rdar://22222026 Date Originated:10-Aug-2015 06:30 PM
Status:Open Resolved:
Product:Developer Tools Product Version:Swift 2 beta 5
Classification:Enhancement Reproducible:Not Applicable
 
NSObjectProtocol is more general than NSObject and isEqual and hash are defined in NSObjectProtocol. Logically, we should inherit NSObjectProtocol from Equatable and Hashable.

Why not? Why instead extend NSObject to conform to Equatable and Hashable?

The current design causes problems like this:

if obj.delegate == self {
Binary operator '==' cannot be applied to operands of type 'XXXDelegate' and 'XXXDelegate'
because delegates are NSObjectProtocol not NSObject.

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!