Skip to content

Commit 75ea47d

Browse files
authored
Merge pull request #67314 from hborla/missing-peer-property-metadata
[IRGen] Visit members generated by peer macros in ClassDataBuilder.
2 parents 93a70a0 + b746a03 commit 75ea47d

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

include/swift/AST/TypeMemberVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class TypeMemberVisitor : public DeclVisitor<ImplClass, RetTy> {
7171
///
7272
/// \seealso IterableDeclContext::getImplementationContext()
7373
void visitImplementationMembers(NominalTypeDecl *D) {
74-
for (Decl *member : D->getImplementationContext()->getMembers()) {
74+
for (Decl *member : D->getImplementationContext()->getAllMembers()) {
7575
asImpl().visit(member);
7676
}
7777

lib/Sema/TypeCheckDecl.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2855,7 +2855,14 @@ static ArrayRef<Decl *> evaluateMembersRequest(
28552855
if (auto *vd = dyn_cast<ValueDecl>(member)) {
28562856
// Add synthesized members to a side table and sort them by their mangled
28572857
// name, since they could have been added to the class in any order.
2858-
if (vd->isSynthesized()) {
2858+
if (vd->isSynthesized() &&
2859+
// FIXME: IRGen requires the distributed actor synthesized
2860+
// properties to be in a specific order that is different
2861+
// from ordering by their mangled name, so preserve the order
2862+
// they were added in.
2863+
!(nominal &&
2864+
(vd == nominal->getDistributedActorIDProperty() ||
2865+
vd == nominal->getDistributedActorSystemProperty()))) {
28592866
synthesizedMembers.add(vd);
28602867
return;
28612868
}

lib/Sema/TypeCheckDistributed.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ void swift::checkDistributedActorProperties(const NominalTypeDecl *decl) {
681681
if (id == C.Id_actorSystem || id == C.Id_id) {
682682
prop->diagnose(diag::distributed_actor_user_defined_special_property,
683683
id);
684+
prop->setInvalid();
684685
}
685686
}
686687
}

test/decl/protocol/special/DistributedActor.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ distributed actor D2 {
3838
// expected-error@-1{{actor 'D2' has no initializers}}
3939
let actorSystem: String
4040
// expected-error@-1{{property 'actorSystem' cannot be defined explicitly, as it conflicts with distributed actor synthesized stored property}}
41-
// expected-error@-2{{invalid redeclaration of synthesized implementation for protocol requirement 'actorSystem'}}
42-
// expected-note@-3{{stored property 'actorSystem' without initial value prevents synthesized initializers}}
41+
// expected-note@-2{{stored property 'actorSystem' without initial value prevents synthesized initializers}}
4342
}
4443

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

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

5654
let actorSystem: String
5755
// expected-error@-1{{property 'actorSystem' cannot be defined explicitly, as it conflicts with distributed actor synthesized stored property}}
58-
// expected-error@-2{{invalid redeclaration of synthesized implementation for protocol requirement 'actorSystem'}}
59-
// expected-note@-3{{stored property 'actorSystem' without initial value prevents synthesized initializers}}
56+
// expected-note@-2{{stored property 'actorSystem' without initial value prevents synthesized initializers}}
6057
let id: OtherActorIdentity
6158
// expected-error@-1{{property 'id' cannot be defined explicitly, as it conflicts with distributed actor synthesized stored property}}
62-
// expected-error@-2{{invalid redeclaration of synthesized implementation for protocol requirement 'id'}}
63-
// expected-note@-3{{stored property 'id' without initial value prevents synthesized initializers}}
59+
// expected-note@-2{{stored property 'id' without initial value prevents synthesized initializers}}
6460
}
6561

6662
protocol P1: DistributedActor {

0 commit comments

Comments
 (0)