Skip to content

Commit c5d2cac

Browse files
committed
[stdlib] Restore the _copy function.
Deprecate it in swift 6.
1 parent 91e88db commit c5d2cac

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

stdlib/public/core/LifetimeManager.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,12 @@ extension String {
265265
}
266266
}
267267
#endif
268+
269+
@available(*, deprecated, message: "Use the copy operator")
270+
@_alwaysEmitIntoClient
271+
@inlinable
272+
@_transparent
273+
@_semantics("lifetimemanagement.copy")
274+
public func _copy<T>(_ value: T) -> T {
275+
copy value
276+
}

test/stdlib/LifetimeManagement.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ class Klass {}
88

99
var suite = TestSuite("LifetimeManagement")
1010

11+
suite.test("_copy") {
12+
let k = Klass()
13+
expectTrue(k === _copy(k))
14+
}
15+
1116
suite.test("copy") {
1217
let k = Klass()
1318
expectTrue(k === copy k)

0 commit comments

Comments
 (0)