Skip to content
Merged
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
31 changes: 27 additions & 4 deletions lib/Sema/DerivedConformanceDistributedActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,9 +424,30 @@ static FuncDecl *deriveDistributedActorSystem_invokeHandlerOnReturn(
/******************************* PROPERTIES ***********************************/
/******************************************************************************/

// NOTE: There is no deriveDistributedActor_aid since it must be handled earlier
// due to the Identifiable Conformance it must fulfil as well.
// TODO(distributed): try to bring back `id` synthesis from addImplicitDistributedActorIDProperty to Derived infra
static ValueDecl *deriveDistributedActor_id(DerivedConformance &derived) {
assert(derived.Nominal->isDistributedActor());
auto &C = derived.Context;

// ```
// nonisolated let id: Self.ID // Self.ActorSystem.ActorID
// ```
auto propertyType = getDistributedActorIDType(derived.Nominal);

VarDecl *propDecl;
PatternBindingDecl *pbDecl;
std::tie(propDecl, pbDecl) = derived.declareDerivedProperty(
DerivedConformance::SynthesizedIntroducer::Let, C.Id_id, propertyType,
propertyType,
/*isStatic=*/false, /*isFinal=*/true);

// mark as nonisolated, allowing access to it from everywhere
propDecl->getAttrs().add(
new (C) NonisolatedAttr(/*IsImplicit=*/true));

derived.addMemberToConformanceContext(pbDecl, /*insertAtHead=*/true);
derived.addMemberToConformanceContext(propDecl, /*insertAtHead=*/true);
return propDecl;
}

static ValueDecl *deriveDistributedActor_actorSystem(
DerivedConformance &derived) {
Expand Down Expand Up @@ -761,7 +782,9 @@ static void assertRequiredSynthesizedPropertyOrder(DerivedConformance &derived,
ValueDecl *DerivedConformance::deriveDistributedActor(ValueDecl *requirement) {
if (auto var = dyn_cast<VarDecl>(requirement)) {
ValueDecl *derivedValue = nullptr;
if (var->getName() == Context.Id_actorSystem) {
if (var->getName() == Context.Id_id) {
derivedValue = deriveDistributedActor_id(*this);
} else if (var->getName() == Context.Id_actorSystem) {
derivedValue = deriveDistributedActor_actorSystem(*this);
} else if (var->getName() == Context.Id_unownedExecutor) {
derivedValue = deriveDistributedActor_unownedExecutor(*this);
Expand Down