Skip to content

Commit 96d895f

Browse files
committed
[Concurrency] Compute actor isolation for var decls before checking
decl attributes. (cherry picked from commit 275d783)
1 parent 64362ef commit 96d895f

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6636,7 +6636,8 @@ void AttributeChecker::visitNonisolatedAttr(NonisolatedAttr *attr) {
66366636
// backing storage is a stored 'var' that is part of the internal state
66376637
// of the actor which could only be accessed in actor's isolation context.
66386638
if (var->hasAttachedPropertyWrapper()) {
6639-
diagnoseAndRemoveAttr(attr, diag::nonisolated_wrapped_property);
6639+
diagnoseAndRemoveAttr(attr, diag::nonisolated_wrapped_property)
6640+
.warnUntilSwiftVersionIf(attr->isImplicit(), 6);
66406641
return;
66416642
}
66426643

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,6 +2165,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
21652165
(void) VD->getPropertyWrapperAuxiliaryVariables();
21662166
(void) VD->getPropertyWrapperInitializerInfo();
21672167
(void) VD->getImplInfo();
2168+
(void) getActorIsolation(VD);
21682169

21692170
// Visit auxiliary decls first
21702171
VD->visitAuxiliaryDecls([&](VarDecl *var) {

test/Concurrency/global_actor_inference.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ struct HasWrapperOnActor {
390390
synced = 17
391391
}
392392

393-
@WrapperActor var actorSynced: Int = 0
393+
@WrapperActor var actorSynced: Int = 0 // expected-warning{{'nonisolated' is not supported on properties with property wrappers}}
394394

395395
func testActorSynced() {
396396
_ = actorSynced
@@ -491,10 +491,10 @@ struct SimplePropertyWrapper {
491491
class WrappedContainsNonisolatedAttr {
492492
@SimplePropertyWrapper nonisolated var value
493493
// expected-error@-1 {{'nonisolated' is not supported on properties with property wrappers}}
494-
// expected-note@-2 2{{property declared here}}
494+
// expected-note@-2 {{property declared here}}
495495

496496
nonisolated func test() {
497-
_ = value // expected-error {{main actor-isolated property 'value' can not be referenced from a non-isolated context}}
497+
_ = value
498498
_ = $value // expected-error {{main actor-isolated property '$value' can not be referenced from a non-isolated context}}
499499
}
500500
}

test/Concurrency/global_actor_inference_swift6.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ struct HasWrapperOnActor {
117117
synced = 17
118118
}
119119

120-
@WrapperActor var actorSynced: Int = 0
120+
@WrapperActor var actorSynced: Int = 0 // expected-error{{'nonisolated' is not supported on properties with property wrappers}}
121121

122122
func testActorSynced() {
123123
_ = actorSynced

0 commit comments

Comments
 (0)