mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
For an Equatable type, we need a hash implementation that is compatible with any possible definition of `==`. Conservatively, that means `-hash` must return a constant. For non-Equatable types, we know that `==` is identity based, so we can get better hash behavior by using the object address. Caveat: This means that non-Equatable types will do two protocol conformance checks on every call to `hash`.