-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] prevent MutableCollections from inappropriately inheriting a Slice<Self> subscript #38509
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
- add a default implementation of MutableCollection’s subscript(bounds: Range<_>) with the most general signature possible - it is marked unavailable in order to prevent the infinite recursion bug reported in SR-14848 - add a conditionally-available subscript(bounds: Range<_>) -> Slice<Self> only when Subsequence is Slice<Self>. This will supersede the unconditional extension that provides the same signature.
Is there a wizard of availability annotations to help figure out what's needed in the last of these commits? |
@swift-ci please smoke test |
@slavapestov I'd like your opinion on availability annotation and ABI impact of these changes. |
@swift-ci please smoke test |
@swift-ci please smoke test |
@swift-ci please smoke test macOS platform |
As it is, this change is tripping up the api-digester test. I believe that's the not-breaking-things test, so an adjustment is clearly needed. |
The source/abi compatibility tests aren't perfect -- they sometimes report false positives. We also know that this is technically a source breaking change, so I'd expect we'll need to add at least a couple new expected differences. Source compat diff
These are good -- the test correctly caught that we added an extra constraint on the ABI diffs
This one is interesting -- it looks like the compiler generated an implicit If true, then this is indeed an ABI break that needs to be fixed. A quick patch is to add an explicit |
@swift-ci please smoke test macOS platform |
@swift-ci please smoke test |
@swift-ci please smoke test |
@swift-ci please smoke test macOS platform |
@swift-ci please smoke test Linux platform |
@lorentey Thanks for confirming I wasn't breaking anything I shouldn't break! |
adds a conditional protocol extension that defines
MutableCollection.MutableCollection.subscript(bounds: Range<_>) -> Slice<Self>
only whenSubSequence == Slice<Self>
.attempts to mark the unconditional extension method
MutableCollection.subscript(bounds: Range<_>) -> Slice<Self>
as unavailableMutableCollection
s whereSubSequence == Slice<Self>
still get the expected default implementation.adds a default implementation of
MutableCollection.subscript(bounds: Range<_>) -> SubSequence
, marked unavailable, in order to prevent invalid conformances from compiling whenSubSequence
is notSlice<Self>
.Resolves SR-14850 / rdar://79898408 (and completes the fix to SR-14848).