Skip to content

Commit 493c867

Browse files
committed
[Concurrency] Don't complain about interpolation variables being mutated.
Implicitly-generated interpolation variables are mutated within the autoclosures created by a `spawn let`. Don't complain about them being concurrently accessed, because they aren't. Fixes rdar://76020473.
1 parent 42e6342 commit 493c867

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,6 +1918,10 @@ namespace {
19181918
// Check whether this is a local variable, in which case we can
19191919
// determine whether it was safe to access concurrently.
19201920
if (auto var = dyn_cast<VarDecl>(value)) {
1921+
// Ignore interpolation variables.
1922+
if (var->getBaseName() == ctx.Id_dollarInterpolation)
1923+
return false;
1924+
19211925
auto parent = mutableLocalVarParent[declRefExpr];
19221926

19231927
// If the variable is immutable, it's fine so long as it involves

test/decl/var/spawn_let.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,8 @@ func cook() async throws {
3838
_ = try await veggies
3939
_ = await meat
4040
}
41+
42+
func testInterpolation() async {
43+
spawn let x = "\(12345)"
44+
_ = await x
45+
}

0 commit comments

Comments
 (0)