-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add custom AnyHashable representations to bridged Foundation types #1649
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add custom AnyHashable representations to bridged Foundation types #1649
Conversation
This ensures bridgable values are interchangeable with their bridged counterparts when converted to AnyHashable, improving the usefulness of AnyHashable and increasing consistency across platforms.
Hm, this looks like a legitimate issue:
|
Ah, it's https://bugs.swift.org/browse/SR-7284 in a new disguise. print(["foo", "bar"] as [Any] as? AnyHashable) // ⇒ nil
print(["foo", "bar"] as [Any] as AnyObject as? AnyHashable) // ⇒ Optional(AnyHashable([AnyHashable("foo"), AnyHashable("bar")])) |
@swift-ci test |
(While I'm not happy that we have bugs, I'm happy when the bugs are the same across platforms, so that if and when we face them we can fix them on all platforms.) |
8057125
to
dd824ed
Compare
@swift-ci please test |
Oh, this patch has merge conflicts. Can you resolve them? |
Yes, I'll take a look soon! |
Closing older PRs after re-core of swift-corelibs-foundation on swift-foundation (#5001). |
When converted to
AnyHashable
, both forms of bridged types should hash the same way and compare as identical. To implement this, we need to add_HasCustomAnyHashableRepresentation
conformances to all bridgableNSObject
subclasses.This PR brings the set of types with custom
AnyHashable
representations in swift-corelibs-foundation in sync with the Foundation overlay in apple/swift.Resolves https://bugs.swift.org/browse/SR-7436
Note that the new tests require the hashing fixes in #1645, #1646, #1647 and #1648.