Skip to content

Commit c34f705

Browse files
committed
Detach enable-experimental-async-top-level flag
SE-0343 is approved so it's time to pull the feature out from behind the experimental feature flag. This patch pulls it out and deprecates passing the flag to the frontend so that we can pull it out entirely eventually.
1 parent b183ae1 commit c34f705

File tree

6 files changed

+14
-21
lines changed

6 files changed

+14
-21
lines changed

include/swift/AST/DiagnosticsFrontend.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,8 @@ ERROR(error_nonexistent_output_dir,none,
420420
REMARK(interface_file_backup_used,none,
421421
"building module from '%0' failed; retrying building module from '%1'", (StringRef, StringRef))
422422

423+
WARNING(warn_flag_deprecated,none, "flag '%0' is deprecated", (StringRef))
424+
423425
// Dependency Verifier Diagnostics
424426
ERROR(missing_member_dependency,none,
425427
"expected "

include/swift/Basic/LangOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,9 +407,6 @@ namespace swift {
407407
/// cases.
408408
bool EnableNonFrozenEnumExhaustivityDiagnostics = false;
409409

410-
/// Enable making top-level code support concurrency
411-
bool EnableExperimentalAsyncTopLevel = false;
412-
413410
/// Regex for the passes that should report passed and missed optimizations.
414411
///
415412
/// These are shared_ptrs so that this class remains copyable.

lib/AST/Decl.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9088,9 +9088,7 @@ ActorIsolation swift::getActorIsolationOfContext(DeclContext *dc) {
90889088
}
90899089

90909090
if (auto *tld = dyn_cast<TopLevelCodeDecl>(dc)) {
9091-
if (dc->isAsyncContext() ||
9092-
(dc->getASTContext().LangOpts.WarnConcurrency &&
9093-
dc->getASTContext().LangOpts.EnableExperimentalAsyncTopLevel)) {
9091+
if (dc->isAsyncContext() || dc->getASTContext().LangOpts.WarnConcurrency) {
90949092
if (Type mainActor = dc->getASTContext().getMainActorType())
90959093
return ActorIsolation::forGlobalActor(mainActor, /*unsafe=*/false);
90969094
}

lib/AST/DeclContext.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,12 +1239,10 @@ bool DeclContext::isAsyncContext() const {
12391239
return false;
12401240
case DeclContextKind::FileUnit:
12411241
if (const SourceFile *sf = dyn_cast<SourceFile>(this))
1242-
return getASTContext().LangOpts.EnableExperimentalAsyncTopLevel &&
1243-
sf->isAsyncTopLevelSourceFile();
1242+
return sf->isAsyncTopLevelSourceFile();
12441243
return false;
12451244
case DeclContextKind::TopLevelCodeDecl:
1246-
return getASTContext().LangOpts.EnableExperimentalAsyncTopLevel &&
1247-
getParent()->isAsyncContext();
1245+
return getParent()->isAsyncContext();
12481246
case DeclContextKind::AbstractClosureExpr:
12491247
return cast<AbstractClosureExpr>(this)->isBodyAsync();
12501248
case DeclContextKind::AbstractFunctionDecl: {

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,16 +487,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
487487
Opts.DisableImplicitConcurrencyModuleImport |=
488488
Args.hasArg(OPT_disable_implicit_concurrency_module_import);
489489

490-
Opts.EnableExperimentalAsyncTopLevel |=
491-
Args.hasArg(OPT_enable_experimental_async_top_level);
492-
493490
/// experimental distributed also implicitly enables experimental concurrency
494491
Opts.EnableExperimentalDistributed |=
495492
Args.hasArg(OPT_enable_experimental_distributed);
496493
Opts.EnableExperimentalConcurrency |=
497494
Args.hasArg(OPT_enable_experimental_distributed);
498-
Opts.EnableExperimentalConcurrency |=
499-
Args.hasArg(OPT_enable_experimental_async_top_level);
495+
496+
if (Args.hasArg(OPT_enable_experimental_async_top_level))
497+
Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated,
498+
"-enable-experimental-async-top-level");
500499

501500
Opts.DiagnoseInvalidEphemeralnessAsError |=
502501
Args.hasArg(OPT_enable_invalid_ephemeralness_as_error);

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,14 @@ GlobalActorAttributeRequest::evaluate(
344344
if (auto var = dyn_cast<VarDecl>(storage)) {
345345

346346
// ... but not if it's an async-context top-level global
347-
if (var->getASTContext().LangOpts.EnableExperimentalAsyncTopLevel &&
348-
var->isTopLevelGlobal() && (var->getDeclContext()->isAsyncContext()
349-
|| var->getASTContext().LangOpts.WarnConcurrency)) {
347+
if (var->isTopLevelGlobal() &&
348+
(var->getDeclContext()->isAsyncContext() ||
349+
var->getASTContext().LangOpts.WarnConcurrency)) {
350350
var->diagnose(diag::global_actor_top_level_var)
351351
.highlight(globalActorAttr->getRangeWithAt());
352352
return None;
353353
}
354-
354+
355355
// ... and not if it's local property
356356
if (var->getDeclContext()->isLocalContext()) {
357357
var->diagnose(diag::global_actor_on_local_variable, var->getName())
@@ -3869,8 +3869,7 @@ ActorIsolation ActorIsolationRequest::evaluate(
38693869
}
38703870

38713871
if (auto var = dyn_cast<VarDecl>(value)) {
3872-
if (var->getASTContext().LangOpts.EnableExperimentalAsyncTopLevel &&
3873-
var->isTopLevelGlobal() &&
3872+
if (var->isTopLevelGlobal() &&
38743873
(var->getASTContext().LangOpts.WarnConcurrency ||
38753874
var->getDeclContext()->isAsyncContext())) {
38763875
if (Type mainActor = var->getASTContext().getMainActorType())

0 commit comments

Comments
 (0)