File tree 2 files changed +30
-1
lines changed
2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -238,6 +238,7 @@ extension MutableCollection {
238
238
/// the range must be valid indices of the collection.
239
239
///
240
240
/// - Complexity: O(1)
241
+ @available ( * , unavailable)
241
242
@inlinable
242
243
public subscript( bounds: Range < Index > ) -> Slice < Self > {
243
244
get {
@@ -282,7 +283,7 @@ extension MutableCollection {
282
283
}
283
284
}
284
285
285
- @available ( SwiftStdlib 5 . 5 , * )
286
+ @available ( SwiftStdlib 9999 , * )
286
287
extension MutableCollection where SubSequence == Slice < Self > {
287
288
288
289
/// Accesses a contiguous subrange of the collection's elements.
@@ -310,6 +311,7 @@ extension MutableCollection where SubSequence == Slice<Self> {
310
311
///
311
312
/// - Complexity: O(1)
312
313
@inlinable
314
+ @_alwaysEmitIntoClient
313
315
public subscript( bounds: Range < Index > ) -> Slice < Self > {
314
316
get {
315
317
_failEarlyRangeCheck ( bounds, bounds: startIndex..< endIndex)
Original file line number Diff line number Diff line change @@ -173,6 +173,33 @@ struct MutableCollectionWithNonDefaultSubSequence: MutableCollection {
173
173
}
174
174
}
175
175
176
+ struct MutableCollectionWithDefaultSubSequence : MutableCollection {
177
+ public var startIndex : Int
178
+ public var endIndex : Int
179
+
180
+ public func index( after i: Int ) -> Int { i+ 1 }
181
+ public subscript( position: Int ) -> Int {
182
+ get { position }
183
+ set { _ = newValue }
184
+ }
185
+ }
186
+
187
+ func subscriptMutableCollectionIgnored( ) {
188
+ let cs : MutableCollectionWithNonDefaultSubSequence
189
+ cs = . init( startIndex: 0 , endIndex: 10 )
190
+
191
+ let badSlice : Slice < MutableCollectionWithNonDefaultSubSequence >
192
+ badSlice = cs [ 0 ..< 2 ] // expected-error {{'subscript(_:)' is unavailable}}
193
+ cs [ 3 ..< 5 ] = badSlice // expected-error {{'subscript(_:)' is unavailable}}
194
+
195
+ let ds : MutableCollectionWithDefaultSubSequence
196
+ ds = . init( startIndex: 0 , endIndex: 10 )
197
+
198
+ let goodSlice : Slice < MutableCollectionWithDefaultSubSequence >
199
+ goodSlice = ds [ 0 ..< 2 ]
200
+ ds [ 3 ..< 5 ] = goodSlice
201
+ }
202
+
176
203
// FIXME: Remove -verify-ignore-unknown.
177
204
// <unknown>:0: error: unexpected note produced: possibly intended match
178
205
// <unknown>:0: error: unexpected note produced: possibly intended match
You can’t perform that action at this time.
0 commit comments