Skip to content

Commit 7cb6581

Browse files
committed
[caller-isolation] Move "interception" of Nonisolated from attribute to a more logical place.
Specifically, rather than performing the interception in ActorIsolationRequest itself after we have returned an actor isolation from getIsolationFromAttributes, just do it in getIsolationFromAttributes. The reason I am doing this is then the code around how we infer isolation in such a case is centralized in getIsolationFromAttributes instead of being in both places. This is a NFC change.
1 parent e4887c7 commit 7cb6581

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4752,6 +4752,17 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
47524752
// If the declaration is explicitly marked 'nonisolated', report it as
47534753
// independent.
47544754
if (nonisolatedAttr) {
4755+
// If the nonisolated async inherits isolation from context is set, return
4756+
// caller isolation inheriting.
4757+
if (decl->getASTContext().LangOpts.hasFeature(
4758+
Feature::NonIsolatedAsyncInheritsIsolationFromContext)) {
4759+
if (auto *func = dyn_cast<AbstractFunctionDecl>(decl);
4760+
func && func->hasAsync() &&
4761+
func->getModuleContext() == decl->getASTContext().MainModule) {
4762+
return ActorIsolation::forCallerIsolationInheriting();
4763+
}
4764+
}
4765+
47554766
return ActorIsolation::forNonisolated(nonisolatedAttr->isUnsafe());
47564767
}
47574768

@@ -5616,15 +5627,6 @@ InferredActorIsolation ActorIsolationRequest::evaluate(
56165627
checkClassGlobalActorIsolation(classDecl, *isolationFromAttr);
56175628
}
56185629

5619-
if (ctx.LangOpts.hasFeature(
5620-
Feature::NonIsolatedAsyncInheritsIsolationFromContext)) {
5621-
if (auto *func = dyn_cast<AbstractFunctionDecl>(value);
5622-
func && func->hasAsync() && isolationFromAttr->isNonisolated() &&
5623-
func->getModuleContext() == ctx.MainModule) {
5624-
return {ActorIsolation::forCallerIsolationInheriting(), {}};
5625-
}
5626-
}
5627-
56285630
return {*isolationFromAttr,
56295631
IsolationSource(/*source*/ nullptr, IsolationSource::Explicit)};
56305632
}

0 commit comments

Comments
 (0)