mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
The copy operator has been implemented and doesn't use it. Remove `Builtin.copy` and `_copy` as much as currently possible. Source compatibility requires that `_copy` remain in the stdlib. It is deprecated here and just uses the copy operator. Handling old swiftinterfaces requires that `Builtin.copy` be defined. Redefine it here as a passthrough--SILGen machinery will produce the necessary copy_addr. rdar://127502242
45 lines
778 B
Swift
45 lines
778 B
Swift
// RUN: %target-run-simple-swift(-Xfrontend -enable-experimental-move-only -enable-builtin-module)
|
|
|
|
// REQUIRES: executable_test
|
|
|
|
import StdlibUnittest
|
|
import Builtin
|
|
|
|
class Klass {}
|
|
|
|
var suite = TestSuite("LifetimeManagement")
|
|
|
|
suite.test("_copy") {
|
|
let k = Klass()
|
|
expectTrue(k === _copy(k))
|
|
}
|
|
|
|
suite.test("copy") {
|
|
let k = Klass()
|
|
expectTrue(k === copy k)
|
|
}
|
|
|
|
suite.test("move") {
|
|
let k = Klass()
|
|
let k2 = k
|
|
expectTrue(k2 === consume k)
|
|
}
|
|
|
|
runAllTests()
|
|
|
|
// TODO: Remove. Only exists to avoid a reverse condfail.
|
|
// rdar://127516085 (Complete removal of Builtin.copy)
|
|
func _oldCopy<T>(_ value: T) -> T {
|
|
#if $BuiltinCopy
|
|
Builtin.copy(value)
|
|
#else
|
|
value
|
|
#endif
|
|
}
|
|
|
|
suite.test("_oldCopy") {
|
|
let k = Klass()
|
|
expectTrue(k === _oldCopy(k))
|
|
}
|
|
|