Files
swift-mirror/test/Concurrency/unavailable_from_async_swift6.swift
Pavel Yaskevich 00fe5632d7 [TypeChecker] Downgrade noasync availability to warnings on @preconcurrency declarations
This change helps to stage in new `async` overloads in Swift 6 language mode
if `@preconcurrency` declaration is not available from async contexts.
2025-01-17 14:01:34 -08:00

21 lines
671 B
Swift

// RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple -swift-version 6
// REQUIRES: concurrency
// REQUIRES: asserts
struct API {
@available(*, noasync, message: "use complete() instead")
func wait() {}
@preconcurrency
@available(*, noasync, message: "use complete() instead")
func waitUntilComplete() {}
func complete() async {}
}
func test(v: API) async {
v.wait() // expected-error {{instance method 'wait' is unavailable from asynchronous contexts; use complete() instead}}
v.waitUntilComplete() // expected-warning {{instance method 'waitUntilComplete' is unavailable from asynchronous contexts; use complete() instead}}
}