Files
swift-mirror/test/Concurrency/optional_isolated_parameters.swift
Eric Miotto 90ccd30335 [Concurrency] prevent two tests from running on OSes without ...
...runtime support

Addresses rdar://159026098
2025-08-29 15:36:09 -07:00

32 lines
762 B
Swift

// RUN: %empty-directory(%t)
// RUN: %target-build-swift -target %target-swift-5.1-abi-triple %s -o %t/main
// RUN: %target-codesign %t/main
// RUN: %target-run %t/main | %FileCheck %s
// REQUIRES: executable_test
// REQUIRES: concurrency
// REQUIRES: concurrency_runtime
// rdar://124277662
// XFAIL: freestanding
actor MyActor: CustomStringConvertible {
let description = "MyActor"
}
func optionalIsolated(to actor: isolated (any Actor)?) {
actor?.assertIsolated()
if let actor {
print("isolated to \(actor)")
} else {
print("nonisolated")
}
}
// CHECK: nonisolated
// CHECK: isolated to Swift.MainActor
// CHECK: isolated to MyActor
optionalIsolated(to: nil)
optionalIsolated(to: MainActor.shared)
await optionalIsolated(to: MyActor())