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 {
736
736
// Variables declared in top-level code are @_predatesConcurrency
737
737
if (const VarDecl *var = dyn_cast<VarDecl>(this )) {
738
738
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 ();
741
741
}
742
742
743
743
return false ;
@@ -8946,9 +8946,8 @@ ActorIsolation swift::getActorIsolationOfContext(DeclContext *dc) {
8946
8946
}
8947
8947
8948
8948
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 ())
8952
8951
return ActorIsolation::forGlobalActor (mainActor, /* unsafe=*/ false );
8953
8952
}
8954
8953
}
Original file line number Diff line number Diff line change @@ -271,8 +271,7 @@ GlobalActorAttributeRequest::evaluate(
271
271
} else if (auto storage = dyn_cast<AbstractStorageDecl>(decl)) {
272
272
// Subscripts and properties are fine...
273
273
if (auto var = dyn_cast<VarDecl>(storage)) {
274
- if (var->isTopLevelGlobal () &&
275
- var->getASTContext ().LangOpts .EnableExperimentalAsyncTopLevel ) {
274
+ if (var->isTopLevelGlobal () && var->getDeclContext ()->isAsyncContext ()) {
276
275
var->diagnose (diag::global_actor_top_level_var)
277
276
.highlight (globalActorAttr->getRangeWithAt ());
278
277
return None;
@@ -3510,10 +3509,8 @@ ActorIsolation ActorIsolationRequest::evaluate(
3510
3509
}
3511
3510
3512
3511
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 ())
3517
3514
return inferredIsolation (
3518
3515
ActorIsolation::forGlobalActor (mainActor,
3519
3516
/* unsafe=*/ var->preconcurrency ()));
Original file line number Diff line number Diff line change @@ -1492,9 +1492,7 @@ class Context {
1492
1492
static Context forTopLevelCode (TopLevelCodeDecl *D) {
1493
1493
// Top-level code implicitly handles errors.
1494
1494
return Context (/* handlesErrors=*/ true ,
1495
- /* handlesAsync=*/
1496
- D->getASTContext ().LangOpts .EnableExperimentalAsyncTopLevel ,
1497
- None);
1495
+ /* handlesAsync=*/ D->isAsyncContext (), None);
1498
1496
}
1499
1497
1500
1498
static Context forFunction (AbstractFunctionDecl *D) {
You can’t perform that action at this time.
0 commit comments