Skip to content

Commit b746a03

Browse files
committed
[Distributed] Avoid cascading diagnostics when actorSystem is declared
explicitly.
1 parent 58ad17a commit b746a03

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

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)