-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SR-12881] DefaultIndices dynamic dispatch #32019
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
Conversation
As seen in SR-12881, `DefaultIndices` was not properly dispatching certain `Collection` requirements through conditional conformances to `BidirectionalCollection` and `RandomAccessCollection`. This should fix that.
Co-authored-by: Xiaodi Wu <[email protected]>
Co-authored-by: Xiaodi Wu <[email protected]>
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.
This is a good change in principle, but the impact on ABI stability needs to be considered. These maybe need to be always emitted into client, or need availability annotations.
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.
This looks good — thanks! 👍
Could you please also add unit tests for the correct behavior?
Co-authored-by: Karoy Lorentey <[email protected]>
I’d be happy to, but I’ve never added unit tests to Swift before: where should they go, and is there a particular form or style that they should adopt? |
Most stdlib tests live under // RUN: %target-run-stdlib-swift
// REQUIRES: executable_test
import StdlibUnittest
var suite = TestSuite("DefaultIndices")
defer { runAllTests() }
suite.test("Some name") {
expectEqual(4, 2 + 2)
} For the most part, the assertion syntax is equivalent to XCTest, with the The |
@airspeedswift, I changed @lorentey, I added unit tests to exercise SR-12881, do they look acceptable? |
@swift-ci please test |
Build failed |
Build failed |
Curiously, these requirements are declared So, IIUC, any conforming type that wants to perfectly forward implementations of these to another, user-supplied, collection needs to do this three different times for the (unlikely but not impossible) case that the target collection distinguishes between This change still looks right to me. We are currently lacking stdlib tests for this rarely exercised language facility; if it turns out we need to add more code, we'll be able to do it later. Cc @DougGregor |
@swift-ci test and merge |
|
@vedantk It looks like swiftlang/llvm-project#1442 got automerged to llvm-project/master, but it doesn't work there. |
This will be resolved by swiftlang/llvm-project#1446. |
@swift-ci test |
1 similar comment
@swift-ci test |
@lorentey sorry about that, I wasn't aware of the fact that swift/release/5.3 auto-merges into swift/master for llvm-project. I'll keep this in mind going forward. |
As seen in SR-12881,
DefaultIndices
was not properly dispatching certainCollection
requirements through conditional conformances toBidirectionalCollection
andRandomAccessCollection
. This should fix that by adding implementations for these methods at the point whereDefaultIndices
conforms toCollection
: