File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-swift-frontend -swift-version 4 -O %s -emit-sil | %FileCheck %s
2
+
3
+ // This test is testing that even in presence of
4
+ // RangeReplaceableCollection.filter(_:), Arrays are still calling the default
5
+ // implementation from Sequence.
6
+
7
+ // CHECK-NOT: RangeReplaceableCollection.filter(_:)
8
+ @inline ( never)
9
+ public func foobar( _ xs: [ Int ] ) -> [ Int ] {
10
+ return xs. filter { _ in false }
11
+ }
12
+
Original file line number Diff line number Diff line change @@ -20,10 +20,20 @@ tests.test("Array.filter return type") {
20
20
expectType ( [ Int ] . self, & filtered)
21
21
}
22
22
23
+ tests. test ( " ContiguousArray.filter return type " ) {
24
+ var filtered = ContiguousArray ( 0 ..< 10 ) . filter { $0 % 2 == 0 }
25
+ expectType ( [ Int ] . self, & filtered)
26
+ }
27
+
28
+ tests. test ( " ArraySlice.filter return type " ) {
29
+ var filtered = Array ( 0 ..< 10 ) [ 0 ..< 10 ] . filter { $0 % 2 == 0 }
30
+ expectType ( [ Int ] . self, & filtered)
31
+ }
32
+
23
33
tests. test ( " String.filter can return [Character] " ) {
24
34
let filtered = " Hello, World " . filter { " A " <= $0 && $0 <= " Z " } as [ Character ]
25
35
expectEqualSequence ( " HW " , filtered)
26
36
}
27
37
28
-
29
38
runAllTests ( )
39
+
You can’t perform that action at this time.
0 commit comments