mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Instead, use the `%target-swift-5.1-abi-triple` substitution to compile the tests for deployment to the minimum OS versions required for use of _Concurrency APIs.
37 lines
705 B
Swift
37 lines
705 B
Swift
// RUN: %target-run-simple-swift(-target %target-swift-5.1-abi-triple -enable-actor-data-race-checks -swift-version 5 -strict-concurrency=minimal) | %FileCheck %s
|
|
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: concurrency
|
|
// REQUIRES: concurrency_runtime
|
|
// UNSUPPORTED: freestanding
|
|
|
|
@preconcurrency @MainActor
|
|
protocol P {
|
|
func requirement()
|
|
}
|
|
|
|
class C: P {
|
|
func requirement() {
|
|
call {
|
|
print("don't crash!")
|
|
}
|
|
}
|
|
|
|
var task: Task<Void, Never>?
|
|
|
|
@preconcurrency func call(closure: @escaping @Sendable () -> Void) {
|
|
task = Task.detached {
|
|
closure()
|
|
}
|
|
}
|
|
|
|
func wait() async {
|
|
await task?.value
|
|
}
|
|
}
|
|
|
|
// CHECK: don't crash!
|
|
let c = C()
|
|
c.requirement()
|
|
await c.wait()
|