File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -244,6 +244,10 @@ public protocol _RangeReplaceableIndexable : _Indexable {
244
244
public protocol RangeReplaceableCollection
245
245
: _RangeReplaceableIndexable , Collection
246
246
{
247
+ // FIXME(ABI): should require `RangeReplaceableCollection`.
248
+ associatedtype SubSequence : _RangeReplaceableIndexable /*: RangeReplaceableCollection*/
249
+ = RangeReplaceableSlice < Self >
250
+
247
251
//===--- Fundamental Requirements ---------------------------------------===//
248
252
249
253
/// Creates a new, empty collection.
@@ -540,6 +544,9 @@ public protocol RangeReplaceableCollection
540
544
//===----------------------------------------------------------------------===//
541
545
542
546
extension RangeReplaceableCollection {
547
+ public subscript( bounds: Range < Index > ) -> RangeReplaceableSlice < Self > {
548
+ return RangeReplaceableSlice ( base: self , bounds: bounds)
549
+ }
543
550
544
551
/// Creates a new collection containing the specified number of a single,
545
552
/// repeated value.
Original file line number Diff line number Diff line change @@ -116,3 +116,27 @@ struct BadBidirectionalIndexable : BidirectionalIndexable {
116
116
// expected-error@+1 {{'index(after:)' has different argument names from those required by protocol '_BidirectionalIndexable' ('index(before:)'}}
117
117
func index( after i: Int ) -> Int { return 0 }
118
118
}
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
+ subscript( pos: Int ) -> Int { return 0 }
129
+
130
+ func index( after: Int ) -> Int { fatalError ( ) }
131
+ func index( before: Int ) -> Int { fatalError ( ) }
132
+ func index( _: Int , offsetBy: Int ) -> Int { fatalError ( ) }
133
+ func distance( from: Int , to: Int ) -> Int { fatalError ( ) }
134
+
135
+ mutating func replaceSubrange< C> (
136
+ _ subrange: Range < Int > ,
137
+ with newElements: C
138
+ ) where C : Collection , C. Iterator. Element == Int {
139
+ fatalError ( )
140
+ }
141
+ }
142
+
You can’t perform that action at this time.
0 commit comments