Skip to content

Commit 1fa2d16

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 41f42fa commit 1fa2d16

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
@@ -1879,6 +1879,10 @@ namespace {
18791879
// Check whether this is a local variable, in which case we can
18801880
// determine whether it was safe to access concurrently.
18811881
if (auto var = dyn_cast<VarDecl>(value)) {
1882+
// Ignore interpolation variables.
1883+
if (var->getBaseName() == ctx.Id_dollarInterpolation)
1884+
return false;
1885+
18821886
auto parent = mutableLocalVarParent[declRefExpr];
18831887

18841888
// 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)