Swift: linker errors with Hashable & Equatable conformance in two separate files
| Originator: | rix.rob | ||
| Number: | rdar://17489254 | Date Originated: | 27-Jun-2014 05:06 PM |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode6-Beta2 (6A216f) |
| Classification: | Serious Bug | Reproducible: | Always |
Summary:
Swift fails to link projects which declare Hashable & Equatable conformance for the same type in two separate files.
Steps to Reproduce:
1. Declare a new type.
2. In separate files, explicitly conform it to Hashable & Equatable respectively using extensions, implementing the requirements for those protocols.
3. Build.
Expected Results:
I expected it to build & run just fine; the explicit conformance to Equatable is redundant, but not unreasonable as documentation.
Actual Results:
Instead, it fails with linker errors.
Regression:
This works fine if both extensions are in the same file.
Notes:
Code listing as follows:
File A:
struct Thing {
let value: Int
}
File B:
extension Thing : Hashable {
var hashValue: Int { return value }
}
File C:
extension Thing : Equatable {}
func == (a: Thing, b: Thing) { return a.value == b.value }
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!