Files
swift-mirror/test/Interpreter/moveonly_deinit_autoclosure.swift
Kavon Farvardin 0420310623 NCGenerics: it's no longer "experimental"
resolves rdar://127701059
2024-05-08 10:49:12 -07:00

36 lines
559 B
Swift

// RUN: %target-run-simple-swift
// REQUIRES: executable_test
internal func _myPrecondition(
_ body: @autoclosure () -> Bool
) {
guard body() else {
fatalError("condition failed")
}
}
var deinitCounter = 0
struct MyCounter<T>: ~Copyable {
let expectedCount = 1
let box: T
init(_ t: T) {
self.box = t
}
deinit {
print("hello")
deinitCounter += 1
_myPrecondition(deinitCounter == self.expectedCount)
}
}
func test() {
_ = MyCounter(4343)
}
// CHECK: hello
test()
// CHECK-NEXT: great success
print("great success")