[AST] NFC: Add a convenient way to create implicit NonisolatedAttrs

This commit is contained in:
Pavel Yaskevich
2025-04-10 16:45:56 -07:00
parent 3896f8fd77
commit 826176a28a
11 changed files with 29 additions and 39 deletions

View File

@@ -465,8 +465,7 @@ static ValueDecl *deriveDistributedActor_id(DerivedConformance &derived) {
/*isStatic=*/false, /*isFinal=*/true);
// mark as nonisolated, allowing access to it from everywhere
propDecl->getAttrs().add(
new (C) NonisolatedAttr(/*unsafe=*/false, /*implicit=*/true));
propDecl->getAttrs().add(NonisolatedAttr::createImplicit(C));
derived.addMemberToConformanceContext(pbDecl, /*insertAtHead=*/true);
derived.addMemberToConformanceContext(propDecl, /*insertAtHead=*/true);
@@ -496,8 +495,7 @@ static ValueDecl *deriveDistributedActor_actorSystem(
propertyType, /*isStatic=*/false, /*isFinal=*/true);
// mark as nonisolated, allowing access to it from everywhere
propDecl->getAttrs().add(
new (C) NonisolatedAttr(/*unsafe=*/false, /*implicit=*/true));
propDecl->getAttrs().add(NonisolatedAttr::createImplicit(C));
// IMPORTANT: `id` MUST be the first field of a distributed actor, and
// `actorSystem` MUST be the second field, because for a remote instance
@@ -795,8 +793,7 @@ static ValueDecl *deriveDistributedActor_unownedExecutor(DerivedConformance &der
property->getAttrs().add(new (ctx) SemanticsAttr(SEMANTICS_DEFAULT_ACTOR,
SourceLoc(), SourceRange(),
/*implicit*/ true));
property->getAttrs().add(
new (ctx) NonisolatedAttr(/*unsafe=*/false, /*implicit=*/true));
property->getAttrs().add(NonisolatedAttr::createImplicit(ctx));
// Make the property implicitly final.
property->getAttrs().add(new (ctx) FinalAttr(/*IsImplicit=*/true));