mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
This ensures that move checking sees the cleanups when determining a value's lifetime and doesn't try to insert its own cleanup leading to a double destroy. Fixes #85063 | rdar://163194098.
41 lines
561 B
Swift
41 lines
561 B
Swift
// RUN: %target-run-simple-swift
|
|
// REQUIRES: executable_test
|
|
|
|
struct Butt: Error {}
|
|
|
|
struct Inside: ~Copyable {
|
|
init() throws { throw Butt() }
|
|
}
|
|
|
|
class C {
|
|
deinit { print("destroying") }
|
|
}
|
|
|
|
struct Outside: ~Copyable {
|
|
let instance: Inside
|
|
var c: C
|
|
|
|
init() throws {
|
|
c = C()
|
|
let instance = try Inside()
|
|
self.instance = instance
|
|
}
|
|
}
|
|
|
|
// CHECK: begin
|
|
// CHECK-NEXT: destroying
|
|
// CHECK-NEXT: caught
|
|
// CHECK-NEXT: end
|
|
|
|
func test() {
|
|
print("begin")
|
|
do {
|
|
_ = try Outside()
|
|
} catch {
|
|
print("caught")
|
|
}
|
|
print("end")
|
|
}
|
|
test()
|
|
|