@@ -112,7 +112,7 @@ struct MinimalCollectionWith${Implementation}Filter<Element>
112
112
}
113
113
114
114
func filter(
115
- @ noescape _ transform: ( Element ) throws -> Bool
115
+ _ transform: @ noescape ( Element) throws -> Bool
116
116
) rethrows -> [ Element ] {
117
117
MinimalCollectionWithCustomFilter . timesFilterWasCalled += 1
118
118
return try _data. filter ( transform)
@@ -126,7 +126,7 @@ struct MinimalCollectionWith${Implementation}Filter<Element>
126
126
127
127
func callStaticCollectionFilter(
128
128
_ sequence: MinimalCollectionWithDefaultFilter < OpaqueValue < Int > > ,
129
- @ noescape includeElement: ( OpaqueValue < Int > ) -> Bool
129
+ includeElement: @ noescape ( OpaqueValue < Int > ) -> Bool
130
130
) -> [ OpaqueValue < Int > ] {
131
131
var result = sequence. filter ( includeElement)
132
132
expectType ( [ OpaqueValue < Int > ] . self, & result)
@@ -135,7 +135,7 @@ func callStaticCollectionFilter(
135
135
136
136
func callStaticCollectionFilter(
137
137
_ sequence: MinimalCollectionWithCustomFilter < OpaqueValue < Int > > ,
138
- @ noescape includeElement: ( OpaqueValue < Int > ) -> Bool
138
+ includeElement: @ noescape ( OpaqueValue < Int > ) -> Bool
139
139
) -> [ OpaqueValue < Int > ] {
140
140
var result = sequence. filter ( includeElement)
141
141
expectType ( [ OpaqueValue < Int > ] . self, & result)
@@ -144,7 +144,7 @@ func callStaticCollectionFilter(
144
144
145
145
func callGenericCollectionFilter< S : Collection > (
146
146
_ sequence: S ,
147
- @ noescape includeElement: ( S . Iterator . Element ) -> Bool
147
+ includeElement: @ noescape ( S . Iterator . Element ) -> Bool
148
148
) -> [ S . Iterator . Element ] {
149
149
var result = sequence. filter ( includeElement)
150
150
expectType ( Array< S . Iterator. Element> . self , & result)
@@ -249,7 +249,7 @@ struct MinimalCollectionWith${Implementation}Map<Element>
249
249
}
250
250
251
251
func map< T> (
252
- @ noescape _ transform: ( Element ) throws -> T
252
+ _ transform: @ noescape ( Element) throws -> T
253
253
) rethrows -> [ T ] {
254
254
MinimalCollectionWithCustomMap . timesMapWasCalled += 1
255
255
return try _data. map ( transform)
@@ -263,7 +263,7 @@ struct MinimalCollectionWith${Implementation}Map<Element>
263
263
264
264
func callStaticCollectionMap< T> (
265
265
_ collection: MinimalCollectionWithDefaultMap < OpaqueValue < Int > > ,
266
- @ noescape transform: ( OpaqueValue < Int > ) -> T
266
+ transform: @ noescape ( OpaqueValue < Int > ) -> T
267
267
) -> [ T ] {
268
268
var result = collection. map ( transform)
269
269
expectType ( [ T ] . self, & result)
@@ -272,7 +272,7 @@ func callStaticCollectionMap<T>(
272
272
273
273
func callStaticCollectionMap< T> (
274
274
_ collection: MinimalCollectionWithCustomMap < OpaqueValue < Int > > ,
275
- @ noescape transform: ( OpaqueValue < Int > ) -> T
275
+ transform: @ noescape ( OpaqueValue < Int > ) -> T
276
276
) -> [ T ] {
277
277
var result = collection. map ( transform)
278
278
expectType ( [ T ] . self, & result)
@@ -281,7 +281,7 @@ func callStaticCollectionMap<T>(
281
281
282
282
func callGenericCollectionMap< C : Collection , T> (
283
283
_ collection: C ,
284
- @ noescape transform: ( C . Iterator . Element ) -> T
284
+ transform: @ noescape ( C . Iterator . Element ) -> T
285
285
) -> [ T ] {
286
286
var result = collection. map ( transform)
287
287
expectType ( [ T ] . self, & result)
@@ -588,6 +588,26 @@ CollectionTypeTests.test("subscript(_: Range<Index>)/writeback") {
588
588
[ 1 , 2 , 3 , 4 , 5 , 0 , - 1 , - 2 , - 3 , - 4 ] , collection)
589
589
}
590
590
591
+ CollectionTypeTests . test ( " subscript(_: Range<Index>)/defaultImplementation/sliceTooLarge " )
592
+ . crashOutputMatches ( " Cannot replace a slice of a MutableCollection with a slice of a larger size " )
593
+ . code {
594
+ var x = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
595
+ expectCrashLater ( )
596
+ x. withUnsafeMutableBufferPointer { buffer in
597
+ buffer [ 2 ..< 4 ] = buffer [ 4 ..< 8 ]
598
+ }
599
+ }
600
+
601
+ CollectionTypeTests . test ( " subscript(_: Range<Index>)/defaultImplementation/sliceTooSmall " )
602
+ . crashOutputMatches ( " Cannot replace a slice of a MutableCollection with a slice of a smaller size " )
603
+ . code {
604
+ var x = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 ]
605
+ expectCrashLater ( )
606
+ x. withUnsafeMutableBufferPointer { buffer in
607
+ buffer [ 2 ..< 6 ] = buffer [ 6 ..< 8 ]
608
+ }
609
+ }
610
+
591
611
//===----------------------------------------------------------------------===//
592
612
// isEmpty
593
613
//===----------------------------------------------------------------------===//
@@ -730,7 +750,7 @@ CollectionTypeTests.test("index(of:)/ContinueSearch") {
730
750
731
751
CollectionTypeTests . test ( " Collection/split/dispatch " ) {
732
752
var tester = CollectionLog . dispatchTester ( [ OpaqueValue ( 1 ) ] )
733
- tester. split { $0. value == 1 }
753
+ _ = tester. split { $0. value == 1 }
734
754
expectCustomizable ( tester, tester. log. split)
735
755
}
736
756
@@ -740,7 +760,7 @@ CollectionTypeTests.test("Collection/split/dispatch") {
740
760
741
761
CollectionTypeTests . test ( " Collection/prefix(through:)/dispatch " ) {
742
762
var tester = CollectionLog . dispatchTester ( [ 1 , 2 , 3 ] . map ( OpaqueValue . init) )
743
- tester. prefix ( through: 1 )
763
+ _ = tester. prefix ( through: 1 )
744
764
expectCustomizable ( tester, tester. log. prefixThrough)
745
765
}
746
766
@@ -750,7 +770,7 @@ CollectionTypeTests.test("Collection/prefix(through:)/dispatch") {
750
770
751
771
CollectionTypeTests . test ( " Collection/prefix(upTo:)/dispatch " ) {
752
772
var tester = CollectionLog . dispatchTester ( [ OpaqueValue ( 1 ) ] )
753
- tester. prefix ( upTo: 1 )
773
+ _ = tester. prefix ( upTo: 1 )
754
774
expectCustomizable ( tester, tester. log. prefixUpTo)
755
775
}
756
776
@@ -760,7 +780,7 @@ CollectionTypeTests.test("Collection/prefix(upTo:)/dispatch") {
760
780
761
781
CollectionTypeTests . test ( " Collection/suffix(from:)/dispatch " ) {
762
782
var tester = CollectionLog . dispatchTester ( [ 1 , 2 , 3 ] . map ( OpaqueValue . init) )
763
- tester. suffix ( from: 1 )
783
+ _ = tester. suffix ( from: 1 )
764
784
expectCustomizable ( tester, tester. log. suffixFrom)
765
785
}
766
786
0 commit comments