@@ -699,7 +699,7 @@ static bool isAsyncCall(
699699 if (lookup->isImplicitlyAsync ())
700700 return true ;
701701
702- return isAsyncDecl ( lookup->getDecl ());
702+ return lookup->getDecl (). getDecl ()-> isAsync ( );
703703}
704704
705705// / Determine whether we should diagnose data races within the current context.
@@ -2042,24 +2042,6 @@ static ActorIsolation getInnermostIsolatedContext(
20422042 }
20432043}
20442044
2045- // / Determine whether this declaration is always accessed asynchronously.
2046- bool swift::isAsyncDecl (ConcreteDeclRef declRef) {
2047- auto decl = declRef.getDecl ();
2048-
2049- // An async function is asynchronously accessed.
2050- if (auto func = dyn_cast<AbstractFunctionDecl>(decl))
2051- return func->hasAsync ();
2052-
2053- // A computed property or subscript that has an 'async' getter
2054- // is asynchronously accessed.
2055- if (auto storageDecl = dyn_cast<AbstractStorageDecl>(decl)) {
2056- if (auto effectfulGetter = storageDecl->getEffectfulGetAccessor ())
2057- return effectfulGetter->hasAsync ();
2058- }
2059-
2060- return false ;
2061- }
2062-
20632045AbstractFunctionDecl *swift::enclosingUnsafeInheritsExecutor (
20642046 const DeclContext *dc) {
20652047 for (; dc; dc = dc->getParent ()) {
@@ -4443,7 +4425,7 @@ namespace {
44434425 // Make sure isolated conformances are formed in the right context.
44444426 checkIsolatedConformancesInContext (declRef, loc, getDeclContext ());
44454427
4446- auto decl = declRef.getDecl ();
4428+ auto * const decl = declRef.getDecl ();
44474429
44484430 // If this declaration is a callee from the enclosing application,
44494431 // it's already been checked via the call.
@@ -4500,7 +4482,7 @@ namespace {
45004482
45014483 // An escaping partial application of something that is part of
45024484 // the actor's isolated state is never permitted.
4503- if (partialApply && partialApply->isEscaping && !isAsyncDecl (declRef )) {
4485+ if (partialApply && partialApply->isEscaping && !decl-> isAsync ( )) {
45044486 ctx.Diags .diagnose (loc, diag::actor_isolated_partial_apply, decl);
45054487 return true ;
45064488 }
@@ -5612,9 +5594,9 @@ static OverrideIsolationResult validOverrideIsolation(
56125594 // It's okay to enter the actor when the overridden declaration is
56135595 // asynchronous (because it will do the switch) or is accessible from
56145596 // anywhere.
5615- if (isAsyncDecl ( overridden) ||
5616- isAccessibleAcrossActors (
5617- overridden, refResult. isolation , declContext)) {
5597+ if (overridden-> isAsync ( ) ||
5598+ isAccessibleAcrossActors (overridden, refResult. isolation ,
5599+ declContext)) {
56185600 return OverrideIsolationResult::Sendable;
56195601 }
56205602
@@ -7713,13 +7695,15 @@ ActorReferenceResult ActorReferenceResult::forReference(
77137695 std::optional<ActorIsolation> knownContextIsolation,
77147696 llvm::function_ref<ActorIsolation(AbstractClosureExpr *)>
77157697 getClosureActorIsolation) {
7698+ auto *const decl = declRef.getDecl ();
7699+
77167700 // If not provided, compute the isolation of the declaration, adjusted
77177701 // for references.
77187702 ActorIsolation declIsolation = ActorIsolation::forUnspecified ();
77197703 if (knownDeclIsolation) {
77207704 declIsolation = *knownDeclIsolation;
77217705 } else {
7722- declIsolation = getActorIsolationForReference (declRef. getDecl () , fromDC);
7706+ declIsolation = getActorIsolationForReference (decl , fromDC);
77237707 if (declIsolation.requiresSubstitution ())
77247708 declIsolation = declIsolation.subst (declRef.getSubstitutions ());
77257709 }
@@ -7731,7 +7715,7 @@ ActorReferenceResult ActorReferenceResult::forReference(
77317715 // FIXME: Actor constructors are modeled as isolated to the actor
77327716 // so that Sendable checking is applied to their arguments, but the
77337717 // call itself does not hop to another executor.
7734- if (auto ctor = dyn_cast<ConstructorDecl>(declRef. getDecl () )) {
7718+ if (auto ctor = dyn_cast<ConstructorDecl>(decl )) {
77357719 if (auto nominal = ctor->getDeclContext ()->getSelfNominalTypeDecl ()) {
77367720 if (nominal->isAnyActor ())
77377721 options |= Flags::OnlyArgsCrossIsolation;
@@ -7740,7 +7724,7 @@ ActorReferenceResult ActorReferenceResult::forReference(
77407724
77417725 // If the entity we are referencing is not a value, we're in the same
77427726 // concurrency domain.
7743- if (isNonValueReference (declRef. getDecl () ))
7727+ if (isNonValueReference (decl ))
77447728 return forSameConcurrencyDomain (declIsolation, options);
77457729
77467730 // Compute the isolation of the context, if not provided.
@@ -7757,9 +7741,10 @@ ActorReferenceResult ActorReferenceResult::forReference(
77577741 if (!declIsolation.isActorIsolated ()) {
77587742 // If the declaration is asynchronous and we are in an actor-isolated
77597743 // context (of any kind), then we exit the actor to the nonisolated context.
7760- if (isAsyncDecl (declRef) && contextIsolation.isActorIsolated () &&
7761- !declRef.getDecl ()->getAttrs ()
7762- .hasAttribute <UnsafeInheritExecutorAttr>())
7744+ if (decl->isAsync () && contextIsolation.isActorIsolated () &&
7745+ !declRef.getDecl ()
7746+ ->getAttrs ()
7747+ .hasAttribute <UnsafeInheritExecutorAttr>())
77637748 return forExitsActorToNonisolated (contextIsolation, options);
77647749
77657750 // Otherwise, we stay in the same concurrency domain, whether on an actor
@@ -7788,11 +7773,9 @@ ActorReferenceResult ActorReferenceResult::forReference(
77887773 if ((declIsolation.isActorIsolated () && contextIsolation.isGlobalActor ()) ||
77897774 declIsolation.isGlobalActor ()) {
77907775 auto *init = dyn_cast<ConstructorDecl>(fromDC);
7791- auto *decl = declRef.getDecl ();
77927776 if (init && init->isDesignatedInit () && isStoredProperty (decl) &&
77937777 (!actorInstance || actorInstance->isSelf ())) {
7794- auto type =
7795- fromDC->mapTypeIntoContext (declRef.getDecl ()->getInterfaceType ());
7778+ auto type = fromDC->mapTypeIntoContext (decl->getInterfaceType ());
77967779 if (!type->isSendableType ()) {
77977780 // Treat the decl isolation as 'preconcurrency' to downgrade violations
77987781 // to warnings, because violating Sendable here is accepted by the
@@ -7806,16 +7789,14 @@ ActorReferenceResult ActorReferenceResult::forReference(
78067789 // If there is an instance and it is checked by flow isolation, treat it
78077790 // as being in the same concurrency domain.
78087791 if (actorInstance &&
7809- checkedByFlowIsolation (
7810- fromDC, *actorInstance, declRef.getDecl (), declRefLoc, useKind))
7792+ checkedByFlowIsolation (fromDC, *actorInstance, decl, declRefLoc, useKind))
78117793 return forSameConcurrencyDomain (declIsolation, options);
78127794
78137795 // If we are delegating to another initializer, treat them as being in the
78147796 // same concurrency domain.
78157797 // FIXME: This has a lot of overlap with both the stored-property checks
78167798 // below and the flow-isolation checks above.
7817- if (actorInstance && actorInstance->isSelf () &&
7818- isa<ConstructorDecl>(declRef.getDecl ()) &&
7799+ if (actorInstance && actorInstance->isSelf () && isa<ConstructorDecl>(decl) &&
78197800 isa<ConstructorDecl>(fromDC))
78207801 return forSameConcurrencyDomain (declIsolation, options);
78217802
@@ -7824,16 +7805,15 @@ ActorReferenceResult ActorReferenceResult::forReference(
78247805 // global-actor-qualified type, then we have problems if the stored property
78257806 // type is non-Sendable. Note that if we get here, the type must be Sendable.
78267807 if (actorInstance && actorInstance->isSelf () &&
7827- isNonInheritedStorage (declRef.getDecl (), fromDC) &&
7828- declIsolation.isGlobalActor () &&
7808+ isNonInheritedStorage (decl, fromDC) && declIsolation.isGlobalActor () &&
78297809 (isa<ConstructorDecl>(fromDC) || isa<DestructorDecl>(fromDC)))
78307810 return forSameConcurrencyDomain (declIsolation, options);
78317811
78327812 // At this point, we are accessing the target from outside the actor.
78337813 // First, check whether it is something that can be accessed directly,
78347814 // without any kind of promotion.
7835- if (isAccessibleAcrossActors (
7836- declRef. getDecl (), declIsolation, fromDC, options, actorInstance))
7815+ if (isAccessibleAcrossActors (decl, declIsolation, fromDC, options,
7816+ actorInstance))
78377817 return forEntersActor (declIsolation, options);
78387818
78397819 // This is a cross-actor reference.
@@ -7843,7 +7823,7 @@ ActorReferenceResult ActorReferenceResult::forReference(
78437823 options |= Flags::Preconcurrency;
78447824
78457825 // If the declaration isn't asynchronous, promote to async.
7846- if (!isAsyncDecl (declRef ))
7826+ if (!decl-> isAsync ( ))
78477827 options |= Flags::AsyncPromotion;
78487828
78497829 // If the declaration is isolated to a distributed actor and we are not
0 commit comments