Skip to content

Commit 614dcfc

Browse files
committed
Allow global actors on stored properties
1 parent 8a4cb8b commit 614dcfc

File tree

3 files changed

+1
-12
lines changed

3 files changed

+1
-12
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4446,8 +4446,6 @@ ERROR(global_actor_on_actor_class,none,
44464446
"actor class %0 cannot have a global actor", (Identifier))
44474447
ERROR(global_actor_on_local_variable,none,
44484448
"local variable %0 cannot have a global actor", (DeclName))
4449-
ERROR(global_actor_on_struct_property,none,
4450-
"stored property %0 of a struct cannot have a global actor", (DeclName))
44514449
ERROR(global_actor_non_unsafe_init,none,
44524450
"global actor attribute %0 argument can only be '(unsafe)'", (Type))
44534451

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -458,15 +458,6 @@ GlobalActorAttributeRequest::evaluate(
458458
.highlight(globalActorAttr->getRangeWithAt());
459459
return None;
460460
}
461-
462-
// Global actors don't make sense on a stored property of a struct.
463-
if (var->hasStorage() && var->getDeclContext()->getSelfStructDecl() &&
464-
var->isInstanceMember()) {
465-
var->diagnose(diag::global_actor_on_struct_property, var->getName())
466-
.highlight(globalActorAttr->getRangeWithAt());
467-
return None;
468-
}
469-
470461
}
471462
} else if (isa<ExtensionDecl>(decl)) {
472463
// Extensions are okay.

test/attr/global_actor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct OtherGlobalActor {
6565
}
6666

6767
@GA1 struct X {
68-
@GA1 var member: Int // expected-error{{stored property 'member' of a struct cannot have a global actor}}
68+
@GA1 var member: Int
6969
}
7070

7171
struct Y {

0 commit comments

Comments
 (0)