Files
swift-mirror/test/Concurrency/actor_data_race_checks_minimal.swift
Allan Shortlidge c02fc4724d Tests: Remove -disable-availability-checking from many Concurrency tests.
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.
2024-10-18 16:21:51 -07:00

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()