Skip to content

Commit bc43430

Browse files
authored
Merge pull request #60037 from tshortli/additional-back-deploy-coroutine-tests
NFC: Update `@_backDeploy` runtime tests to call a coroutine that yields a non-trivial value
2 parents 876f446 + 405b7b7 commit bc43430

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

test/attr/Inputs/BackDeployHelper.swift

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Foundation
12

23
/// Returns the dsohandle for the dynamic library.
34
public func libraryHandle() -> UnsafeRawPointer {
@@ -125,8 +126,8 @@ extension IntArray {
125126
@available(BackDeploy 1.0, *)
126127
@_backDeploy(before: BackDeploy 2.0)
127128
public func print() {
128-
// Tests recursive @_backDeploy since `values` is also @_backDeploy
129-
testPrint(handle: #dsohandle, values.description)
129+
// Tests recursive @_backDeploy since `Array.print()` is also @_backDeploy
130+
_values.print()
130131
}
131132

132133
@available(BackDeploy 1.0, *)
@@ -143,6 +144,12 @@ extension IntArray {
143144
get { _values[i] }
144145
_modify { yield &_values[i] }
145146
}
147+
148+
@available(BackDeploy 1.0, *)
149+
@_backDeploy(before: BackDeploy 2.0)
150+
public var rawValues: [Int] {
151+
_read { yield _values }
152+
}
146153
}
147154

148155
extension ReferenceIntArray {
@@ -153,8 +160,8 @@ extension ReferenceIntArray {
153160
@available(BackDeploy 1.0, *)
154161
@_backDeploy(before: BackDeploy 2.0)
155162
public final func print() {
156-
// Tests recursive @_backDeploy since `values` is also @_backDeploy
157-
testPrint(handle: #dsohandle, values.description)
163+
// Tests recursive @_backDeploy since `Array.print()` is also @_backDeploy
164+
_values.print()
158165
}
159166

160167
@available(BackDeploy 1.0, *)
@@ -177,6 +184,20 @@ extension ReferenceIntArray {
177184
get { _values[i] }
178185
_modify { yield &_values[i] }
179186
}
187+
188+
@available(BackDeploy 1.0, *)
189+
@_backDeploy(before: BackDeploy 2.0)
190+
public final var rawValues: [Int] {
191+
_read { yield _values }
192+
}
193+
}
194+
195+
extension Array {
196+
@available(BackDeploy 1.0, *)
197+
@_backDeploy(before: BackDeploy 2.0)
198+
public func print() {
199+
testPrint(handle: #dsohandle, description)
200+
}
180201
}
181202

182203
#endif // !STRIP_V2_APIS

test/attr/attr_backDeploy_evolution.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,10 @@ do {
151151
// CHECK-ABI: library: [5, 43, 3]
152152
// CHECK-BD: client: [5, 43, 3]
153153
array.print()
154+
155+
// CHECK-ABI: library: [5, 43, 3]
156+
// CHECK-BD: client: [5, 43, 3]
157+
print(array.rawValues.print())
154158
}
155159

156160
do {
@@ -179,4 +183,8 @@ do {
179183
// CHECK-ABI: library: [7, 40, 1]
180184
// CHECK-BD: client: [7, 40, 1]
181185
array.print()
186+
187+
// CHECK-ABI: library: [7, 40, 1]
188+
// CHECK-BD: client: [7, 40, 1]
189+
print(array.rawValues.print())
182190
}

0 commit comments

Comments
 (0)