Skip to content

Commit cc39510

Browse files
authored
Merge pull request #59753 from etcwilde/ewilde/5.7/fix-noasync-warning
🍒5.7: Add missing `warnUntilSwift(6)`
2 parents 90321c4 + eb29d08 commit cc39510

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3587,11 +3587,13 @@ diagnoseDeclUnavailableFromAsync(const ValueDecl *D, SourceRange R,
35873587
return false;
35883588

35893589
ASTContext &ctx = Where.getDeclContext()->getASTContext();
3590+
// @available(noasync) spelling
35903591
if (const AvailableAttr *attr = D->getAttrs().getNoAsync(ctx)) {
35913592
SourceLoc diagLoc = call ? call->getLoc() : R.Start;
35923593
auto diag = ctx.Diags.diagnose(diagLoc, diag::async_unavailable_decl,
35933594
D->getDescriptiveKind(), D->getBaseName(),
35943595
attr->Message);
3596+
diag.warnUntilSwiftVersion(6);
35953597

35963598
if (!attr->Rename.empty()) {
35973599
fixItAvailableAttrRename(diag, R, D, attr, call);
@@ -3604,7 +3606,7 @@ diagnoseDeclUnavailableFromAsync(const ValueDecl *D, SourceRange R,
36043606

36053607
if (!hasUnavailableAttr)
36063608
return false;
3607-
// @available(noasync) spelling
3609+
// @_unavailableFromAsync spelling
36083610
const UnavailableFromAsyncAttr *attr =
36093611
D->getAttrs().getAttribute<UnavailableFromAsyncAttr>();
36103612
SourceLoc diagLoc = call ? call->getLoc() : R.Start;

test/Concurrency/unavailable_from_async.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func makeAsyncClosuresSynchronously(bop: inout Bop) -> (() async -> Void) {
6464
bop.foo() // expected-warning@:9{{'foo' is unavailable from asynchronous contexts}}
6565
bop.muppet() // expected-warning@:9{{'muppet' is unavailable from asynchronous contexts}}
6666
unavailableFunction() // expected-warning@:5{{'unavailableFunction' is unavailable from asynchronous contexts}}
67-
noasyncFunction() // expected-error@:5{{'noasyncFunction' is unavailable from asynchronous contexts}}
67+
noasyncFunction() // expected-warning@:5{{'noasyncFunction' is unavailable from asynchronous contexts}}
6868

6969
// Can use them from synchronous closures
7070
_ = { Bop() }()
@@ -89,7 +89,7 @@ func asyncFunc() async { // expected-error{{asynchronous global function 'asyncF
8989
bop.foo() // expected-warning@:7{{'foo' is unavailable from asynchronous contexts}}
9090
bop.muppet() // expected-warning@:7{{'muppet' is unavailable from asynchronous contexts}}
9191
unavailableFunction() // expected-warning@:3{{'unavailableFunction' is unavailable from asynchronous contexts}}
92-
noasyncFunction() // expected-error@:3{{'noasyncFunction' is unavailable from asynchronous contexts}}
92+
noasyncFunction() // expected-warning@:3{{'noasyncFunction' is unavailable from asynchronous contexts}}
9393

9494
// Unavailable global function
9595
foo() // expected-warning{{'foo' is unavailable from asynchronous contexts}}
@@ -113,7 +113,7 @@ func asyncFunc() async { // expected-error{{asynchronous global function 'asyncF
113113
bop.muppet() // expected-warning@:11{{'muppet' is unavailable from asynchronous contexts}}
114114
_ = Bop() // expected-warning@:11{{'init' is unavailable from asynchronous contexts; Use Bop(a: Int) instead}}
115115
unavailableFunction() // expected-warning@:7{{'unavailableFunction' is unavailable from asynchronous contexts}}
116-
noasyncFunction() // expected-error@:7{{'noasyncFunction' is unavailable from asynchronous contexts}}
116+
noasyncFunction() // expected-warning@:7{{'noasyncFunction' is unavailable from asynchronous contexts}}
117117
}
118118
}
119119

@@ -123,7 +123,7 @@ func asyncFunc() async { // expected-error{{asynchronous global function 'asyncF
123123
bop.foo() // expected-warning@:9{{'foo' is unavailable from asynchronous contexts}}
124124
bop.muppet() // expected-warning@:9{{'muppet' is unavailable from asynchronous contexts}}
125125
unavailableFunction() // expected-warning@:5{{'unavailableFunction' is unavailable from asynchronous contexts}}
126-
noasyncFunction() // expected-error@:5{{'noasyncFunction' is unavailable from asynchronous contexts}}
126+
noasyncFunction() // expected-warning@:5{{'noasyncFunction' is unavailable from asynchronous contexts}}
127127

128128
_ = {
129129
foo()

test/attr/attr_availability_noasync.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ actor IOActor {
2727

2828
@available(SwiftStdlib 5.5, *)
2929
func asyncFunc() async {
30-
// expected-error@+1{{global function 'basicNoAsync' is unavailable from asynchronous contexts}}
30+
// expected-warning@+1{{global function 'basicNoAsync' is unavailable from asynchronous contexts; this is an error in Swift 6}}
3131
basicNoAsync()
3232

33-
// expected-error@+1{{global function 'messageNoAsync' is unavailable from asynchronous contexts; a message from the author}}
33+
// expected-warning@+1{{global function 'messageNoAsync' is unavailable from asynchronous contexts; a message from the author}}
3434
messageNoAsync()
3535

36-
// expected-error@+1{{global function 'renamedNoAsync' is unavailable from asynchronous contexts}}{{5-19=asyncReplacement}}
36+
// expected-warning@+1{{global function 'renamedNoAsync' is unavailable from asynchronous contexts}}{{5-19=asyncReplacement}}
3737
renamedNoAsync() { _ in }
3838

39-
// expected-error@+1{{global function 'readStringFromIO' is unavailable from asynchronous contexts}}{{13-29=IOActor.readString}}
39+
// expected-warning@+1{{global function 'readStringFromIO' is unavailable from asynchronous contexts}}{{13-29=IOActor.readString}}
4040
let _ = readStringFromIO()
4141
}
4242

0 commit comments

Comments
 (0)