Skip to content

Commit 0ee4c9d

Browse files
committed
[Concurrency] bypass global variable static checking for @TaskLocal property wrapper declarations
1 parent 6c75168 commit 0ee4c9d

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4445,6 +4445,13 @@ ActorIsolation ActorIsolationRequest::evaluate(
44454445
if (var->isGlobalStorage() && !isActorType) {
44464446
auto *diagVar = var;
44474447
if (auto *originalVar = var->getOriginalWrappedProperty()) {
4448+
// temporary 5.10 checking bypass for @TaskLocal <rdar://120907014>
4449+
// TODO: @TaskLocal should be a macro <rdar://120914014>
4450+
if (auto *classDecl =
4451+
var->getInterfaceType()->getClassOrBoundGenericClass();
4452+
classDecl && classDecl->getName().is("TaskLocal")) {
4453+
return isolation;
4454+
}
44484455
diagVar = originalVar;
44494456
}
44504457
if (var->isLet()) {

test/Concurrency/global_variables.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ struct TestStatics {
5050
static var computedProperty: Int { 0 } // computed property that, though static, has no storage so is not a global
5151
@TestWrapper static var wrapped: Int // expected-error{{static property 'wrapped' is not concurrency-safe because it is non-isolated global shared mutable state}}
5252
// expected-note@-1{{isolate 'wrapped' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
53+
@TaskLocal static var taskLocal: Int = 0
5354
}
5455

5556
@TestGlobalActor

0 commit comments

Comments
 (0)