-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
| Previous ID | SR-3453 |
| Radar | rdar://problem/31411212 |
| Original Reporter | @airspeedswift |
| Type | Improvement |
| Status | Resolved |
| Resolution | Done |
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Standard Library |
| Labels | Improvement, AffectsABI, swift-evolution-proposal-needed |
| Assignee | @airspeedswift |
| Priority | Medium |
md5: 6d5849c6136f3cb3c380bcd6362f6e00
Issue Description:
Once it is possible in the language (dependent on associated types with where clauses and recursive protocol constraints), the following rules should be enforced:
-
Iteratorshould be aSequence -
Sequence.Iterator.Elementshould becomeSequence.Element -
Sequence.SubSequencemust be aSequence -
Sequence.SubSequence.Elementmust be same type asSequence.Element -
Collection.SubSequence.Indexshould be same type asCollection.Index -
BidirectionalCollection.SubSequenceshould be aBidirectionalCollection -
RandomAccessCollection.SubSequenceshould be aRandomAccessCollection -
RangeReplaceableCollection.SubSequenceshould be aRangeReplaceableCollection -
Collection.Indicesshould be aCollection -
Collection.Indices.Indexshould be same type asCollection.Index -
Collection.SubSequence.Indicesshould be same type asCollection.Indices
Enforcing these rules will massively simplify the writing of generic collections, including several instances in the standard library. See most entries marked FIXME(ABI) with (Associated Types with where clauses) or (Recursive Protocol Constraints) for examples.