Swift: == for NSObject should be a generic function
| Originator: | garth | ||
| Number: | rdar://19756662 | Date Originated: | 07-Feb-2015 01:31 AM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6.2b5 |
| Classification: | Enhancement | Reproducible: | Always |
In the interest of facilitating overloading of the == operator, would it be possible to define the == function for NSobject as a generic instead? That is, instead of func == (lhs: NSObject, rhs: NSObject) -> Bool make it func == <T: NSObject, U: NSObject>(lhs: T, rhs: U) -> Bool The issue is that because the default definition names classes and is not a generic template, it is hard to override. NO possible generic version of ==() can override it, and also NO possible protocol-based version of ==(). That means you’re pretty much stuck adding a separate ==() function of your own for every possible combination of classes.
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!