-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Make all CF types Equatable and Hashable. #4417
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
Make all CF types Equatable and Hashable. #4417
Conversation
Like NSObject, CFType has primitive operations CFEqual and CFHash, so Swift should allow those types to show up in Hashable positions (like dictionaries). The most general way to do this was to introduce a new protocol, _CFObject, and then have the importer automatically make all CF types conform to it. This did require one additional change: the == implementation that calls through to CFEqual is in a new CoreFoundation overlay, but the conformance is in the underlying Clang module. Therefore, operator lookup for conformances has been changed to look in the overlay for an imported declaration (if there is one). https://bugs.swift.org/browse/SR-2388 (cherry picked from commit 361ab62)
@swift-ci Please test macOS |
@parkera, any objections? |
@@ -0,0 +1,23 @@ | |||
//===----------------------------------------------------------------------===// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please name this file something more descriptive than CoreFoundation.swift. CFObject.swift maybe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately our CMake setup currently takes the name of the result file from the name of the first file in the module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would then prefer to see an empty CoreFoundation.swift and this stuff in a more descriptive place.
I really don't like how Foundation.swift became a dumping ground for whatever needed to be put there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, will fix in master. I'll see if the CMake stuff is easy to change, too.
Reverting. New test Interpreter/SDK/cf.swift fails in two places when built with --test-optimized. I don't know if it's a bug here or a miscompile of this code. |
Also reverting #4394 on the 3.0 branch. |
CFHash
function that works across types. This commit adds a new protocol, _CFObject, which includes Hashable and Equatable implementations; it also tweaks protocol checking to allow operator requirements to be found in overlays for a particular module. Note that this will break anyone who implemented Hashable for a CF type themselves.Before merging this pull request to apple/swift repository:
Triggering Swift CI
The swift-ci is triggered by writing a comment on this PR addressed to the GitHub user @swift-ci. Different tests will run depending on the specific comment that you use. The currently available comments are:
Smoke Testing
A smoke test on macOS does the following:
device standard libraries are not built.
version of these tests are not run.
A smoke test on Linux does the following:
tests are not run.
Validation Testing
Lint Testing
Note: Only members of the Apple organization can trigger swift-ci.