Files
swift-mirror/test/Concurrency/isolation_macro_availability.swift
Allan Shortlidge b9e1cbd3ac AST: Enable -unavailable-decl-optimization on visionOS.
Using availability domains, reimplement the algorithm that determines whether a
declaration is unavailable at runtime. The new algorithm takes ABI compatible
platforms into account, ensuring that declarations that are available on iOS do
not get treated as unreachable at runtime when compiling for visionOS.

Resolves rdar://116742214.
2025-02-09 11:19:08 -08:00

29 lines
937 B
Swift

// RUN: %target-typecheck-verify-swift -target %target-pre-stable-abi-triple
// REQUIRES: concurrency
// REQUIRES: swift_swift_parser
// REQUIRES: OS=macosx || OS=ios || OS=tvos || OS=watchos
// rdar://126118470
// UNSUPPORTED: CPU=arm64e
@available(SwiftStdlib 5.1, *)
func isolatedFunc(isolation: isolated (any Actor)? = #isolation) {}
func test() { // expected-note 3 {{add @available attribute to enclosing global function}}
_ = #isolation // expected-error {{'isolation()' is only available in}} expected-note {{add 'if #available' version check}}
isolatedFunc() // expected-error {{'isolatedFunc(isolation:)' is only available in}} expected-note {{add 'if #available' version check}}
// expected-error@-1 {{'isolation()' is only available in}}
if #available(SwiftStdlib 5.1, *) {
_ = #isolation
isolatedFunc()
}
}
@available(SwiftStdlib 5.1, *)
func testAvailable5_1() {
_ = #isolation
isolatedFunc()
}