File tree Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Expand file tree Collapse file tree 1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ // RUN: %target-swift-frontend -module-name test -O -emit-sil -O -primary-file %s | %FileCheck %s
2+
3+ // REQUIRES: optimized_stdlib,swift_stdlib_no_asserts
4+
5+ // Check that there is only a single retain in concat.
6+
7+ // CHECK-LABEL: sil hidden @$s4test6concatyAA14TestCollectionVAD_ADtF :
8+ // CHECK: retain
9+ // CHECK-NOT: retain
10+ // CHECK-NOT: release
11+ // CHECK: apply
12+ // CHECK-NOT: retain
13+ // CHECK-NOT: release
14+ // CHECK: } // end sil function '$s4test6concatyAA14TestCollectionVAD_ADtF'
15+ func concat( _ l: TestCollection , _ r: TestCollection ) -> TestCollection {
16+ l + r
17+ }
18+
19+ struct TestCollection : RandomAccessCollection , RangeReplaceableCollection {
20+ private var base : [ Int ]
21+
22+ init ( base: [ Int ] ) {
23+ self . base = base
24+ }
25+
26+ init ( ) {
27+ self . base = [ ]
28+ }
29+
30+ var startIndex : Int { base. startIndex }
31+
32+ var endIndex : Int { base. endIndex }
33+
34+ subscript( index: Int ) -> Int {
35+ get {
36+ base [ index]
37+ }
38+ set {
39+ base [ index] = newValue
40+ }
41+ }
42+
43+ mutating func replaceSubrange< C> ( _ range: Range < Int > , with newElements: C ) where C: Collection , C. Element == Int {
44+ self . base. replaceSubrange ( range, with: newElements)
45+ }
46+
47+ @inline ( never)
48+ mutating func append< S> ( contentsOf other: S ) where S: Sequence , S. Element == Int {
49+ base. append ( contentsOf: other)
50+ }
51+ }
52+
53+
54+
You can’t perform that action at this time.
0 commit comments