Skip to content

Commit 6d74d44

Browse files
committed
stdlib: make RangeReplaceableCollection.SubSequence a RangeReplaceableCollection
Fixes rdar://problem/28330668.
1 parent eba7550 commit 6d74d44

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

stdlib/public/core/RangeReplaceableCollection.swift.gyb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,9 @@ public protocol _RangeReplaceableIndexable : _Indexable {
244244
public protocol RangeReplaceableCollection
245245
: _RangeReplaceableIndexable, Collection
246246
{
247+
associatedtype SubSequence : RangeReplaceableIndexable /*: RangeReplaceableCollection*/
248+
= RangeReplaceableSlice<Self>
249+
247250
//===--- Fundamental Requirements ---------------------------------------===//
248251

249252
/// Creates a new, empty collection.

validation-test/stdlib/CollectionDiagnostics.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,18 @@ struct BadBidirectionalIndexable : BidirectionalIndexable {
116116
// expected-error@+1 {{'index(after:)' has different argument names from those required by protocol '_BidirectionalIndexable' ('index(before:)'}}
117117
func index(after i: Int) -> Int { return 0 }
118118
}
119+
120+
//
121+
// Check that RangeReplaceableCollection.SubSequence is defaulted.
122+
//
123+
124+
struct RangeReplaceableCollection_SubSequence_IsDefaulted : RangeReplaceableCollection {
125+
var startIndex: Int { fatalError() }
126+
var endIndex: Int { fatalError() }
127+
128+
func index(after: Int) -> Int { fatalError() }
129+
func index(before: Int) -> Int { fatalError() }
130+
func index(_: Int, offsetBy: Int) -> Int { fatalError() }
131+
func distance(from: Int, to: Int) -> Int { fatalError() }
132+
}
133+

0 commit comments

Comments
 (0)