File tree Expand file tree Collapse file tree 3 files changed +8
-14
lines changed Expand file tree Collapse file tree 3 files changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -736,8 +736,8 @@ bool Decl::preconcurrency() const {
736736 // Variables declared in top-level code are @_predatesConcurrency
737737 if (const VarDecl *var = dyn_cast<VarDecl>(this )) {
738738 const LangOptions &langOpts = getASTContext ().LangOpts ;
739- return !langOpts.isSwiftVersionAtLeast (6 ) &&
740- langOpts. EnableExperimentalAsyncTopLevel && var->isTopLevelGlobal ();
739+ return !langOpts.isSwiftVersionAtLeast (6 ) && var-> isTopLevelGlobal () &&
740+ var->getDeclContext ()-> isAsyncContext ();
741741 }
742742
743743 return false ;
@@ -8946,9 +8946,8 @@ ActorIsolation swift::getActorIsolationOfContext(DeclContext *dc) {
89468946 }
89478947
89488948 if (auto *tld = dyn_cast<TopLevelCodeDecl>(dc)) {
8949- ASTContext &ctx = dc->getASTContext ();
8950- if (ctx.LangOpts .EnableExperimentalAsyncTopLevel ) {
8951- if (Type mainActor = ctx.getMainActorType ())
8949+ if (dc->isAsyncContext ()) {
8950+ if (Type mainActor = dc->getASTContext ().getMainActorType ())
89528951 return ActorIsolation::forGlobalActor (mainActor, /* unsafe=*/ false );
89538952 }
89548953 }
Original file line number Diff line number Diff line change @@ -271,8 +271,7 @@ GlobalActorAttributeRequest::evaluate(
271271 } else if (auto storage = dyn_cast<AbstractStorageDecl>(decl)) {
272272 // Subscripts and properties are fine...
273273 if (auto var = dyn_cast<VarDecl>(storage)) {
274- if (var->isTopLevelGlobal () &&
275- var->getASTContext ().LangOpts .EnableExperimentalAsyncTopLevel ) {
274+ if (var->isTopLevelGlobal () && var->getDeclContext ()->isAsyncContext ()) {
276275 var->diagnose (diag::global_actor_top_level_var)
277276 .highlight (globalActorAttr->getRangeWithAt ());
278277 return None;
@@ -3510,10 +3509,8 @@ ActorIsolation ActorIsolationRequest::evaluate(
35103509 }
35113510
35123511 if (auto var = dyn_cast<VarDecl>(value)) {
3513- ASTContext &ctx = var->getASTContext ();
3514- if (var->isTopLevelGlobal () &&
3515- ctx.LangOpts .EnableExperimentalAsyncTopLevel ) {
3516- if (Type mainActor = ctx.getMainActorType ())
3512+ if (var->isTopLevelGlobal () && var->getDeclContext ()->isAsyncContext ()) {
3513+ if (Type mainActor = var->getASTContext ().getMainActorType ())
35173514 return inferredIsolation (
35183515 ActorIsolation::forGlobalActor (mainActor,
35193516 /* unsafe=*/ var->preconcurrency ()));
Original file line number Diff line number Diff line change @@ -1492,9 +1492,7 @@ class Context {
14921492 static Context forTopLevelCode (TopLevelCodeDecl *D) {
14931493 // Top-level code implicitly handles errors.
14941494 return Context (/* handlesErrors=*/ true ,
1495- /* handlesAsync=*/
1496- D->getASTContext ().LangOpts .EnableExperimentalAsyncTopLevel ,
1497- None);
1495+ /* handlesAsync=*/ D->isAsyncContext (), None);
14981496 }
14991497
15001498 static Context forFunction (AbstractFunctionDecl *D) {
You can’t perform that action at this time.
0 commit comments