mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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.
This commit is contained in:
@@ -4147,6 +4147,8 @@ diagnoseDeclAsyncAvailability(const ValueDecl *D, SourceRange R,
|
||||
auto diag = ctx.Diags.diagnose(diagLoc, diag::async_unavailable_decl, D,
|
||||
attr->getMessage());
|
||||
diag.warnUntilSwiftVersion(6);
|
||||
diag.limitBehaviorWithPreconcurrency(DiagnosticBehavior::Warning,
|
||||
D->preconcurrency());
|
||||
|
||||
if (!attr->getRename().empty()) {
|
||||
fixItAvailableAttrRename(diag, R, D, attr->getRename(), call);
|
||||
|
||||
20
test/Concurrency/unavailable_from_async_swift6.swift
Normal file
20
test/Concurrency/unavailable_from_async_swift6.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
// 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}}
|
||||
}
|
||||
Reference in New Issue
Block a user