Skip to content

[5.9][IRGen] Visit members generated by peer macros in ClassDataBuilder. #67315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/swift/AST/TypeMemberVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class TypeMemberVisitor : public DeclVisitor<ImplClass, RetTy> {
///
/// \seealso IterableDeclContext::getImplementationContext()
void visitImplementationMembers(NominalTypeDecl *D) {
for (Decl *member : D->getImplementationContext()->getMembers()) {
for (Decl *member : D->getImplementationContext()->getAllMembers()) {
asImpl().visit(member);
}

Expand Down
9 changes: 8 additions & 1 deletion lib/Sema/TypeCheckDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2855,7 +2855,14 @@ static ArrayRef<Decl *> evaluateMembersRequest(
if (auto *vd = dyn_cast<ValueDecl>(member)) {
// Add synthesized members to a side table and sort them by their mangled
// name, since they could have been added to the class in any order.
if (vd->isSynthesized()) {
if (vd->isSynthesized() &&
// FIXME: IRGen requires the distributed actor synthesized
// properties to be in a specific order that is different
// from ordering by their mangled name, so preserve the order
// they were added in.
!(nominal &&
(vd == nominal->getDistributedActorIDProperty() ||
vd == nominal->getDistributedActorSystemProperty()))) {
synthesizedMembers.add(vd);
return;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Sema/TypeCheckDistributed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ void swift::checkDistributedActorProperties(const NominalTypeDecl *decl) {
if (id == C.Id_actorSystem || id == C.Id_id) {
prop->diagnose(diag::distributed_actor_user_defined_special_property,
id);
prop->setInvalid();
}
}
}
Expand Down
10 changes: 3 additions & 7 deletions test/decl/protocol/special/DistributedActor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,12 @@ distributed actor D2 {
// expected-error@-1{{actor 'D2' has no initializers}}
let actorSystem: String
// expected-error@-1{{property 'actorSystem' cannot be defined explicitly, as it conflicts with distributed actor synthesized stored property}}
// expected-error@-2{{invalid redeclaration of synthesized implementation for protocol requirement 'actorSystem'}}
// expected-note@-3{{stored property 'actorSystem' without initial value prevents synthesized initializers}}
// expected-note@-2{{stored property 'actorSystem' without initial value prevents synthesized initializers}}
}

distributed actor D3 {
var id: Int { 0 }
// expected-error@-1{{property 'id' cannot be defined explicitly, as it conflicts with distributed actor synthesized stored property}}
// expected-error@-2{{invalid redeclaration of synthesized implementation for protocol requirement 'id'}}
}

struct OtherActorIdentity: Sendable, Hashable, Codable {}
Expand All @@ -55,12 +53,10 @@ distributed actor D4 {

let actorSystem: String
// expected-error@-1{{property 'actorSystem' cannot be defined explicitly, as it conflicts with distributed actor synthesized stored property}}
// expected-error@-2{{invalid redeclaration of synthesized implementation for protocol requirement 'actorSystem'}}
// expected-note@-3{{stored property 'actorSystem' without initial value prevents synthesized initializers}}
// expected-note@-2{{stored property 'actorSystem' without initial value prevents synthesized initializers}}
let id: OtherActorIdentity
// expected-error@-1{{property 'id' cannot be defined explicitly, as it conflicts with distributed actor synthesized stored property}}
// expected-error@-2{{invalid redeclaration of synthesized implementation for protocol requirement 'id'}}
// expected-note@-3{{stored property 'id' without initial value prevents synthesized initializers}}
// expected-note@-2{{stored property 'id' without initial value prevents synthesized initializers}}
}

protocol P1: DistributedActor {
Expand Down