Skip to content

Commit d4143ed

Browse files
authored
Merge pull request #78721 from xedin/downgrade-noasync-to-warning-on-preconcurrency-decls
[TypeChecker] Downgrade `noasync` availability to warnings on `@preco…
2 parents 40b3fcc + 00fe563 commit d4143ed

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4157,6 +4157,8 @@ diagnoseDeclAsyncAvailability(const ValueDecl *D, SourceRange R,
41574157
auto diag = ctx.Diags.diagnose(diagLoc, diag::async_unavailable_decl, D,
41584158
attr->getMessage());
41594159
diag.warnUntilSwiftVersion(6);
4160+
diag.limitBehaviorWithPreconcurrency(DiagnosticBehavior::Warning,
4161+
D->preconcurrency());
41604162

41614163
if (!attr->getRename().empty()) {
41624164
fixItAvailableAttrRename(diag, R, D, attr->getRename(), call);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-typecheck-verify-swift -target %target-swift-5.1-abi-triple -swift-version 6
2+
3+
// REQUIRES: concurrency
4+
// REQUIRES: asserts
5+
6+
struct API {
7+
@available(*, noasync, message: "use complete() instead")
8+
func wait() {}
9+
10+
@preconcurrency
11+
@available(*, noasync, message: "use complete() instead")
12+
func waitUntilComplete() {}
13+
14+
func complete() async {}
15+
}
16+
17+
func test(v: API) async {
18+
v.wait() // expected-error {{instance method 'wait' is unavailable from asynchronous contexts; use complete() instead}}
19+
v.waitUntilComplete() // expected-warning {{instance method 'waitUntilComplete' is unavailable from asynchronous contexts; use complete() instead}}
20+
}

0 commit comments

Comments
 (0)