@@ -4933,10 +4933,11 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
4933
4933
// return caller isolation inheriting.
4934
4934
if (decl->getASTContext ().LangOpts .hasFeature (
4935
4935
Feature::NonisolatedNonsendingByDefault)) {
4936
- if (auto *func = dyn_cast<AbstractFunctionDecl>(decl);
4937
- func && func->hasAsync () &&
4938
- func->getModuleContext () == decl->getASTContext ().MainModule ) {
4939
- return ActorIsolation::forCallerIsolationInheriting ();
4936
+ if (auto *value = dyn_cast<ValueDecl>(decl)) {
4937
+ if (value->isAsync () &&
4938
+ value->getModuleContext () == decl->getASTContext ().MainModule ) {
4939
+ return ActorIsolation::forCallerIsolationInheriting ();
4940
+ }
4940
4941
}
4941
4942
}
4942
4943
@@ -5795,11 +5796,9 @@ computeDefaultInferredActorIsolation(ValueDecl *value) {
5795
5796
return *result;
5796
5797
}
5797
5798
5798
- // If we have an async function... by default we inherit isolation.
5799
+ // If we have an async function or storage ... by default we inherit isolation.
5799
5800
if (ctx.LangOpts .hasFeature (Feature::NonisolatedNonsendingByDefault)) {
5800
- if (auto *func = dyn_cast<AbstractFunctionDecl>(value);
5801
- func && func->hasAsync () &&
5802
- func->getModuleContext () == ctx.MainModule ) {
5801
+ if (value->isAsync () && value->getModuleContext () == ctx.MainModule ) {
5803
5802
return {
5804
5803
{ActorIsolation::forCallerIsolationInheriting (), {}}, nullptr , {}};
5805
5804
}
@@ -6212,11 +6211,8 @@ static InferredActorIsolation computeActorIsolation(Evaluator &evaluator,
6212
6211
if (selfTypeIsolation.isolation ) {
6213
6212
auto isolation = selfTypeIsolation.isolation ;
6214
6213
6215
- if (auto *func = dyn_cast<AbstractFunctionDecl>(value);
6216
- ctx.LangOpts .hasFeature (
6217
- Feature::NonisolatedNonsendingByDefault) &&
6218
- func && func->hasAsync () &&
6219
- func->getModuleContext () == ctx.MainModule &&
6214
+ if (ctx.LangOpts .hasFeature (Feature::NonisolatedNonsendingByDefault) &&
6215
+ value->isAsync () && value->getModuleContext () == ctx.MainModule &&
6220
6216
isolation.isNonisolated ()) {
6221
6217
isolation = ActorIsolation::forCallerIsolationInheriting ();
6222
6218
}
0 commit comments