Skip to content

Commit 06dc77d

Browse files
committed
Revert "[Concurrency] Resyntax 'async let' as 'spawn let'."
This reverts commit 41f42fa.
1 parent 8b3147c commit 06dc77d

File tree

10 files changed

+46
-47
lines changed

10 files changed

+46
-47
lines changed

include/swift/AST/DiagnosticsSema.def

+7-7
Original file line numberDiff line numberDiff line change
@@ -4246,8 +4246,8 @@ ERROR(throwing_interpolation_without_try,none,
42464246
"interpolation can throw but is not marked with 'try'", ())
42474247
ERROR(throwing_call_without_try,none,
42484248
"call can throw but is not marked with 'try'", ())
4249-
ERROR(throwing_spawn_let_without_try,none,
4250-
"reading 'spawn let' can throw but is not marked with 'try'", ())
4249+
ERROR(throwing_async_let_without_try,none,
4250+
"reading 'async let' can throw but is not marked with 'try'", ())
42514251
ERROR(throwing_prop_access_without_try,none,
42524252
"property access can throw but is not marked with 'try'", ())
42534253
ERROR(throwing_subscript_access_without_try,none,
@@ -4276,8 +4276,8 @@ NOTE(async_access_without_await,none,
42764276

42774277
NOTE(async_call_without_await_in_autoclosure,none,
42784278
"call is 'async' in an autoclosure argument", ())
4279-
NOTE(async_call_without_await_in_spawn_let,none,
4280-
"call is 'async' in an 'spawn let' initializer", ())
4279+
NOTE(async_call_without_await_in_async_let,none,
4280+
"call is 'async' in an 'async let' initializer", ())
42814281

42824282
WARNING(no_async_in_await,none,
42834283
"no 'async' operations occur within 'await' expression", ())
@@ -4290,7 +4290,7 @@ ERROR(await_in_illegal_context,none,
42904290
"%select{<<ERROR>>|a default argument|a property wrapper initializer|a property initializer|a global variable initializer|an enum case raw value|a catch pattern|a catch guard expression|a defer body}0",
42914291
(unsigned))
42924292
ERROR(async_in_nonasync_function,none,
4293-
"%select{'async'|'async' call|'await'|'spawn let'|'async' property access|'async' subscript access}0 in "
4293+
"%select{'async'|'async' call|'await'|'async let'|'async' property access|'async' subscript access}0 in "
42944294
"%select{a function|an autoclosure}1 that does not support concurrency",
42954295
(unsigned, bool))
42964296
NOTE(note_add_async_to_function,none,
@@ -4428,8 +4428,8 @@ ERROR(actor_isolated_from_concurrent_closure,none,
44284428
ERROR(actor_isolated_from_concurrent_function,none,
44294429
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from a concurrent function",
44304430
(DescriptiveDeclKind, DeclName, unsigned))
4431-
ERROR(actor_isolated_from_spawn_let,none,
4432-
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from 'spawn let' initializer",
4431+
ERROR(actor_isolated_from_async_let,none,
4432+
"actor-isolated %0 %1 cannot be %select{referenced|mutated|used 'inout'}2 from 'async let' initializer",
44334433
(DescriptiveDeclKind, DeclName, unsigned))
44344434
ERROR(actor_isolated_keypath_component,none,
44354435
"cannot form key path to actor-isolated %0 %1",

lib/Sema/TypeCheckConcurrency.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2044,7 +2044,7 @@ namespace {
20442044
if (auto autoclosure = dyn_cast<AutoClosureExpr>(dc)) {
20452045
switch (autoclosure->getThunkKind()) {
20462046
case AutoClosureExpr::Kind::AsyncLet:
2047-
return diag::actor_isolated_from_spawn_let;
2047+
return diag::actor_isolated_from_async_let;
20482048

20492049
case AutoClosureExpr::Kind::DoubleCurryThunk:
20502050
case AutoClosureExpr::Kind::SingleCurryThunk:

lib/Sema/TypeCheckEffects.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1689,7 +1689,7 @@ class Context {
16891689
bool suggestTryFixIt = reasonKind == PotentialEffectReason::Kind::Apply;
16901690

16911691
if (reasonKind == PotentialEffectReason::Kind::AsyncLet) {
1692-
message = diag::throwing_spawn_let_without_try;
1692+
message = diag::throwing_async_let_without_try;
16931693

16941694
} else if (reasonKind == PotentialEffectReason::Kind::PropertyAccess) {
16951695
message = diag::throwing_prop_access_without_try;
@@ -1924,7 +1924,7 @@ class Context {
19241924
if (auto var = dyn_cast<VarDecl>(declRef->getDecl())) {
19251925
if (var->isSpawnLet()) {
19261926
Diags.diagnose(
1927-
e->getLoc(), diag::spawn_let_in_illegal_context,
1927+
e->getLoc(), diag::async_let_in_illegal_context,
19281928
var->getName(), static_cast<unsigned>(getKind()));
19291929
return;
19301930
}
@@ -1935,7 +1935,7 @@ class Context {
19351935
if (patternBinding->isSpawnLet()) {
19361936
auto var = patternBinding->getAnchoringVarDecl(0);
19371937
Diags.diagnose(
1938-
e->getLoc(), diag::spawn_let_in_illegal_context,
1938+
e->getLoc(), diag::async_let_in_illegal_context,
19391939
var->getName(), static_cast<unsigned>(getKind()));
19401940
return;
19411941
}
@@ -2833,7 +2833,7 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
28332833
if (auto var = dyn_cast<VarDecl>(declR->getDecl())) {
28342834
if (var->isSpawnLet()) {
28352835
Ctx.Diags.diagnose(declR->getLoc(),
2836-
diag::spawn_let_without_await,
2836+
diag::async_let_without_await,
28372837
var->getName());
28382838
continue;
28392839
}
@@ -2862,7 +2862,7 @@ class CheckEffectsCoverage : public EffectsHandlingWalker<CheckEffectsCoverage>
28622862
break;
28632863
case AutoClosureExpr::Kind::AsyncLet:
28642864
Ctx.Diags.diagnose(diag.expr.getStartLoc(),
2865-
diag::async_call_without_await_in_spawn_let);
2865+
diag::async_call_without_await_in_async_let);
28662866
break;
28672867
case AutoClosureExpr::Kind::SingleCurryThunk:
28682868
case AutoClosureExpr::Kind::DoubleCurryThunk:

test/Concurrency/spawn_let_isolation.swift test/Concurrency/async_let_isolation.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ actor MyActor {
99
func asynchronous() async -> String { synchronous() }
1010

1111
func testAsyncLetIsolation() async {
12-
spawn let x = self.synchronous()
12+
async let x = self.synchronous()
1313

14-
spawn let y = await self.asynchronous()
14+
async let y = await self.asynchronous()
1515

16-
spawn let z = synchronous()
16+
async let z = synchronous()
1717

1818
var localText = text
19-
spawn let w = localText.removeLast() // expected-error{{mutation of captured var 'localText' in concurrently-executing code}}
19+
async let w = localText.removeLast() // expected-error{{mutation of captured var 'localText' in concurrently-executing code}}
2020

2121
_ = await x
2222
_ = await y
@@ -27,8 +27,8 @@ actor MyActor {
2727

2828
func outside() async {
2929
let a = MyActor()
30-
spawn let x = a.synchronous() // okay, await is implicit
31-
spawn let y = await a.synchronous()
30+
async let x = a.synchronous() // okay, await is implicit
31+
async let y = await a.synchronous()
3232
_ = await x
3333
_ = await y
3434
}

test/Concurrency/await_typo_correction.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@ func async() throws { }
2121
// expected-error@+1 {{found 'async' in expression; did you mean 'await'?}}{{13-18=await}}
2222
let _ = async anotherAsyncFunc()
2323

24-
// Don't emit a diagnostic here related to 'await'
24+
// Don't emit a diagnostic here
2525
async let foo = anotherAsyncFunc()
26-
// expected-warning@-1{{'async let' is now 'spawn let'}}{{5-10=spawn}}
2726
let _ = await foo
2827

2928
// I question the name choice, but it's valid

test/Concurrency/reasync.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,11 @@ func callReasyncWithAutoclosure3() {
149149
reasyncWithAutoclosure2("Hello \(world)")
150150
}
151151

152-
//// spawn let
152+
//// async let
153153

154154
func callReasyncWithAutoclosure4(_: () async -> ()) reasync {
155155
await reasyncFunction {
156-
spawn let x = 123
156+
async let x = 123
157157

158158
_ = await x
159159
}

test/Parse/async.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func testAwaitExpr() async {
7575
func getIntSomeday() async -> Int { 5 }
7676

7777
func testAsyncLet() async {
78-
spawn let x = await getIntSomeday()
78+
async let x = await getIntSomeday()
7979
_ = await x
8080
}
8181

test/decl/var/spawn_let.swift test/decl/var/async_let.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
// REQUIRES: concurrency
44

55
func test() async {
6-
spawn let x = 1 // okay
6+
async let x = 1 // okay
77
_ = await x
88
}
99

1010
struct X {
11-
spawn let x = 1 // expected-error{{'spawn let' can only be used on local declarations}}
11+
async let x = 1 // expected-error{{'async let' can only be used on local declarations}}
1212
// FIXME: expected-error@-1{{'async' call cannot occur in a property initializer}}
1313
}
1414

1515
func testAsyncFunc() async {
16-
spawn let (z1, z2) = (2, 3)
17-
spawn let (_, _) = (2, 3)
18-
spawn let x2 = 1
16+
async let (z1, z2) = (2, 3)
17+
async let (_, _) = (2, 3)
18+
async let x2 = 1
1919

20-
spawn var x = 17 // expected-error{{'spawn' can only be used with 'let' declarations}}{{9-12=let}}
21-
spawn let (_, _) = (1, 2), y2 = 7 // expected-error{{'spawn let' requires at least one named variable}}
22-
spawn let y: Int // expected-error{{'spawn let' binding requires an initializer expression}}
20+
async var x = 17 // expected-error{{'async' can only be used with 'let' declarations}}{{9-12=let}}
21+
async let (_, _) = (1, 2), y2 = 7 // expected-error{{'async let' requires at least one named variable}}
22+
async let y: Int // expected-error{{'async let' binding requires an initializer expression}}
2323
_ = await x
2424
_ = y
2525
_ = await z1
@@ -34,7 +34,7 @@ func chopVegetables() async throws -> [String] { [] }
3434
func marinateMeat() async -> String { "MEAT" }
3535

3636
func cook() async throws {
37-
spawn let veggies = try await chopVegetables(), meat = await marinateMeat()
37+
async let veggies = try await chopVegetables(), meat = await marinateMeat()
3838
_ = try await veggies
3939
_ = await meat
4040
}

test/expr/unary/async_await.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func validAsyncFunction() async throws {
158158
_ = try await throwingAndAsync()
159159
}
160160

161-
// spawn let checking
161+
// Async let checking
162162
func mightThrow() throws { }
163163

164164
func getIntUnsafely() throws -> Int { 0 }
@@ -169,27 +169,27 @@ extension Error {
169169
}
170170

171171
func testAsyncLet() async throws {
172-
spawn let x = await getInt()
172+
async let x = await getInt()
173173
print(x) // expected-error{{expression is 'async' but is not marked with 'await'}}
174-
// expected-note@-1:9{{reference to spawn let 'x' is 'async'}}
174+
// expected-note@-1:9{{reference to async let 'x' is 'async'}}
175175

176176
print(await x)
177177

178178
do {
179179
try mightThrow()
180-
} catch let e where e.number == x { // expected-error{{spawn let 'x' cannot be referenced in a catch guard expression}}
180+
} catch let e where e.number == x { // expected-error{{async let 'x' cannot be referenced in a catch guard expression}}
181181
} catch {
182182
}
183183

184-
spawn let x1 = getIntUnsafely() // okay, try is implicit here
184+
async let x1 = getIntUnsafely() // okay, try is implicit here
185185

186-
spawn let x2 = getInt() // okay, await is implicit here
186+
async let x2 = getInt() // okay, await is implicit here
187187

188-
spawn let x3 = try getIntUnsafely()
189-
spawn let x4 = try! getIntUnsafely()
190-
spawn let x5 = try? getIntUnsafely()
188+
async let x3 = try getIntUnsafely()
189+
async let x4 = try! getIntUnsafely()
190+
async let x5 = try? getIntUnsafely()
191191

192-
_ = await x1 // expected-error{{reading 'spawn let' can throw but is not marked with 'try'}}
192+
_ = await x1 // expected-error{{reading 'async let' can throw but is not marked with 'try'}}
193193
_ = await x2
194194
_ = try await x3
195195
_ = await x4
@@ -198,9 +198,9 @@ func testAsyncLet() async throws {
198198

199199
// expected-note@+1 4{{add 'async' to function 'testAsyncLetOutOfAsync()' to make it asynchronous}} {{30-30= async}}
200200
func testAsyncLetOutOfAsync() {
201-
spawn let x = 1 // expected-error{{'spawn let' in a function that does not support concurrency}}
201+
async let x = 1 // expected-error{{'async let' in a function that does not support concurrency}}
202202
// FIXME: expected-error@-1{{'async' call in a function that does not support concurrency}}
203203

204-
_ = await x // expected-error{{'spawn let' in a function that does not support concurrency}}
205-
_ = x // expected-error{{'spawn let' in a function that does not support concurrency}}
204+
_ = await x // expected-error{{'async let' in a function that does not support concurrency}}
205+
_ = x // expected-error{{'async let' in a function that does not support concurrency}}
206206
}

test/stmt/async.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ func f() async -> Int { 0 }
66

77
_ = await f() // expected-error{{'async' call in a function that does not support concurrency}}
88

9-
spawn let y = await f() // expected-error{{'spawn let' in a function that does not support concurrency}}
9+
async let y = await f() // expected-error{{'async let' in a function that does not support concurrency}}
1010
// expected-error@-1{{'async' call in a function that does not support concurrency}}

0 commit comments

Comments
 (0)