@@ -4951,10 +4951,11 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
4951
4951
// return caller isolation inheriting.
4952
4952
if (decl->getASTContext ().LangOpts .hasFeature (
4953
4953
Feature::NonisolatedNonsendingByDefault)) {
4954
- if (auto *func = dyn_cast<AbstractFunctionDecl>(decl);
4955
- func && func->hasAsync () &&
4956
- func->getModuleContext () == decl->getASTContext ().MainModule ) {
4957
- return ActorIsolation::forCallerIsolationInheriting ();
4954
+ if (auto *value = dyn_cast<ValueDecl>(decl)) {
4955
+ if (value->isAsync () &&
4956
+ value->getModuleContext () == decl->getASTContext ().MainModule ) {
4957
+ return ActorIsolation::forCallerIsolationInheriting ();
4958
+ }
4958
4959
}
4959
4960
}
4960
4961
@@ -5815,11 +5816,9 @@ computeDefaultInferredActorIsolation(ValueDecl *value) {
5815
5816
return *result;
5816
5817
}
5817
5818
5818
- // If we have an async function... by default we inherit isolation.
5819
+ // If we have an async function or storage ... by default we inherit isolation.
5819
5820
if (ctx.LangOpts .hasFeature (Feature::NonisolatedNonsendingByDefault)) {
5820
- if (auto *func = dyn_cast<AbstractFunctionDecl>(value);
5821
- func && func->hasAsync () &&
5822
- func->getModuleContext () == ctx.MainModule ) {
5821
+ if (value->isAsync () && value->getModuleContext () == ctx.MainModule ) {
5823
5822
return {
5824
5823
{ActorIsolation::forCallerIsolationInheriting (), {}}, nullptr , {}};
5825
5824
}
@@ -6232,11 +6231,8 @@ static InferredActorIsolation computeActorIsolation(Evaluator &evaluator,
6232
6231
if (selfTypeIsolation.isolation ) {
6233
6232
auto isolation = selfTypeIsolation.isolation ;
6234
6233
6235
- if (auto *func = dyn_cast<AbstractFunctionDecl>(value);
6236
- ctx.LangOpts .hasFeature (
6237
- Feature::NonisolatedNonsendingByDefault) &&
6238
- func && func->hasAsync () &&
6239
- func->getModuleContext () == ctx.MainModule &&
6234
+ if (ctx.LangOpts .hasFeature (Feature::NonisolatedNonsendingByDefault) &&
6235
+ value->isAsync () && value->getModuleContext () == ctx.MainModule &&
6240
6236
isolation.isNonisolated ()) {
6241
6237
isolation = ActorIsolation::forCallerIsolationInheriting ();
6242
6238
}
0 commit comments