@@ -424,9 +424,30 @@ static FuncDecl *deriveDistributedActorSystem_invokeHandlerOnReturn(
424424/* ****************************** PROPERTIES ***********************************/
425425/* *****************************************************************************/
426426
427- // NOTE: There is no deriveDistributedActor_aid since it must be handled earlier
428- // due to the Identifiable Conformance it must fulfil as well.
429- // TODO(distributed): try to bring back `id` synthesis from addImplicitDistributedActorIDProperty to Derived infra
427+ static ValueDecl *deriveDistributedActor_id (DerivedConformance &derived) {
428+ assert (derived.Nominal ->isDistributedActor ());
429+ auto &C = derived.Context ;
430+
431+ // ```
432+ // nonisolated let id: Self.ID // Self.ActorSystem.ActorID
433+ // ```
434+ auto propertyType = getDistributedActorIDType (derived.Nominal );
435+
436+ VarDecl *propDecl;
437+ PatternBindingDecl *pbDecl;
438+ std::tie (propDecl, pbDecl) = derived.declareDerivedProperty (
439+ DerivedConformance::SynthesizedIntroducer::Let, C.Id_id , propertyType,
440+ propertyType,
441+ /* isStatic=*/ false , /* isFinal=*/ true );
442+
443+ // mark as nonisolated, allowing access to it from everywhere
444+ propDecl->getAttrs ().add (
445+ new (C) NonisolatedAttr (/* IsImplicit=*/ true ));
446+
447+ derived.addMemberToConformanceContext (pbDecl, /* insertAtHead=*/ true );
448+ derived.addMemberToConformanceContext (propDecl, /* insertAtHead=*/ true );
449+ return propDecl;
450+ }
430451
431452static ValueDecl *deriveDistributedActor_actorSystem (
432453 DerivedConformance &derived) {
@@ -761,7 +782,9 @@ static void assertRequiredSynthesizedPropertyOrder(DerivedConformance &derived,
761782ValueDecl *DerivedConformance::deriveDistributedActor (ValueDecl *requirement) {
762783 if (auto var = dyn_cast<VarDecl>(requirement)) {
763784 ValueDecl *derivedValue = nullptr ;
764- if (var->getName () == Context.Id_actorSystem ) {
785+ if (var->getName () == Context.Id_id ) {
786+ derivedValue = deriveDistributedActor_id (*this );
787+ } else if (var->getName () == Context.Id_actorSystem ) {
765788 derivedValue = deriveDistributedActor_actorSystem (*this );
766789 } else if (var->getName () == Context.Id_unownedExecutor ) {
767790 derivedValue = deriveDistributedActor_unownedExecutor (*this );
0 commit comments