Skip to content

Commit 5b1810e

Browse files
committed
More where clauses
1 parent 731a4b5 commit 5b1810e

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

stdlib/public/core/BidirectionalCollection.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public protocol _BidirectionalIndexable : _Indexable {
6565
/// `c.index(before: c.index(after: i)) == i`.
6666
/// - If `i > c.startIndex && i <= c.endIndex`
6767
/// `c.index(after: c.index(before: i)) == i`.
68-
public protocol BidirectionalCollection
69-
: _BidirectionalIndexable, Collection {
68+
public protocol BidirectionalCollection : _BidirectionalIndexable, Collection
69+
where SubSequence: BidirectionalCollection {
7070

7171
// TODO: swift-3-indexing-model - replaces functionality in BidirectionalIndex
7272
/// Returns the position immediately before the given index.
@@ -84,10 +84,7 @@ public protocol BidirectionalCollection
8484

8585
/// A sequence that can represent a contiguous subrange of the collection's
8686
/// elements.
87-
associatedtype SubSequence : _BidirectionalIndexable, Collection
88-
= BidirectionalSlice<Self>
89-
// FIXME(ABI)#93 (Recursive Protocol Constraints):
90-
// associatedtype SubSequence : BidirectionalCollection
87+
associatedtype SubSequence = BidirectionalSlice<Self>
9188

9289
/// A type that represents the indices that are valid for subscripting the
9390
/// collection, in ascending order.

stdlib/public/core/MutableCollection.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,14 +196,9 @@ public protocol _MutableIndexable : _Indexable {
196196
/// // Must be equivalent to:
197197
/// a[i] = x
198198
/// let y = x
199-
public protocol MutableCollection : _MutableIndexable, Collection {
200-
// FIXME(ABI)#181: should be constrained to MutableCollection
201-
// (<rdar://problem/20715009> Implement recursive protocol
202-
// constraints)
203-
/// A collection that represents a contiguous subrange of the collection's
204-
/// elements.
205-
associatedtype SubSequence : Collection /*: MutableCollection*/
206-
= MutableSlice<Self>
199+
public protocol MutableCollection : _MutableIndexable, Collection
200+
where SubSequence: MutableCollection {
201+
associatedtype SubSequence = MutableSlice<Self>
207202

208203
/// Accesses the element at the specified position.
209204
///

stdlib/public/core/RandomAccessCollection.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,11 @@ public protocol _RandomAccessIndexable : _BidirectionalIndexable {
4848
/// `distance(from:to:)` methods with O(1) efficiency.
4949
public protocol RandomAccessCollection :
5050
_RandomAccessIndexable, BidirectionalCollection
51+
where SubSequence: RandomAccessCollection
5152
{
5253
/// A collection that represents a contiguous subrange of the collection's
5354
/// elements.
54-
associatedtype SubSequence : _RandomAccessIndexable, BidirectionalCollection
55-
= RandomAccessSlice<Self>
56-
// FIXME(ABI)#102 (Recursive Protocol Constraints):
57-
// associatedtype SubSequence : RandomAccessCollection
55+
associatedtype SubSequence = RandomAccessSlice<Self>
5856

5957
/// A type that represents the indices that are valid for subscripting the
6058
/// collection, in ascending order.

0 commit comments

Comments
 (0)