mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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.
This commit is contained in:
@@ -420,6 +420,8 @@ ERROR(error_nonexistent_output_dir,none,
|
|||||||
REMARK(interface_file_backup_used,none,
|
REMARK(interface_file_backup_used,none,
|
||||||
"building module from '%0' failed; retrying building module from '%1'", (StringRef, StringRef))
|
"building module from '%0' failed; retrying building module from '%1'", (StringRef, StringRef))
|
||||||
|
|
||||||
|
WARNING(warn_flag_deprecated,none, "flag '%0' is deprecated", (StringRef))
|
||||||
|
|
||||||
// Dependency Verifier Diagnostics
|
// Dependency Verifier Diagnostics
|
||||||
ERROR(missing_member_dependency,none,
|
ERROR(missing_member_dependency,none,
|
||||||
"expected "
|
"expected "
|
||||||
|
|||||||
@@ -407,9 +407,6 @@ namespace swift {
|
|||||||
/// cases.
|
/// cases.
|
||||||
bool EnableNonFrozenEnumExhaustivityDiagnostics = false;
|
bool EnableNonFrozenEnumExhaustivityDiagnostics = false;
|
||||||
|
|
||||||
/// Enable making top-level code support concurrency
|
|
||||||
bool EnableExperimentalAsyncTopLevel = false;
|
|
||||||
|
|
||||||
/// Regex for the passes that should report passed and missed optimizations.
|
/// Regex for the passes that should report passed and missed optimizations.
|
||||||
///
|
///
|
||||||
/// These are shared_ptrs so that this class remains copyable.
|
/// These are shared_ptrs so that this class remains copyable.
|
||||||
|
|||||||
@@ -9088,9 +9088,7 @@ ActorIsolation swift::getActorIsolationOfContext(DeclContext *dc) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (auto *tld = dyn_cast<TopLevelCodeDecl>(dc)) {
|
if (auto *tld = dyn_cast<TopLevelCodeDecl>(dc)) {
|
||||||
if (dc->isAsyncContext() ||
|
if (dc->isAsyncContext() || dc->getASTContext().LangOpts.WarnConcurrency) {
|
||||||
(dc->getASTContext().LangOpts.WarnConcurrency &&
|
|
||||||
dc->getASTContext().LangOpts.EnableExperimentalAsyncTopLevel)) {
|
|
||||||
if (Type mainActor = dc->getASTContext().getMainActorType())
|
if (Type mainActor = dc->getASTContext().getMainActorType())
|
||||||
return ActorIsolation::forGlobalActor(mainActor, /*unsafe=*/false);
|
return ActorIsolation::forGlobalActor(mainActor, /*unsafe=*/false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1239,12 +1239,10 @@ bool DeclContext::isAsyncContext() const {
|
|||||||
return false;
|
return false;
|
||||||
case DeclContextKind::FileUnit:
|
case DeclContextKind::FileUnit:
|
||||||
if (const SourceFile *sf = dyn_cast<SourceFile>(this))
|
if (const SourceFile *sf = dyn_cast<SourceFile>(this))
|
||||||
return getASTContext().LangOpts.EnableExperimentalAsyncTopLevel &&
|
return sf->isAsyncTopLevelSourceFile();
|
||||||
sf->isAsyncTopLevelSourceFile();
|
|
||||||
return false;
|
return false;
|
||||||
case DeclContextKind::TopLevelCodeDecl:
|
case DeclContextKind::TopLevelCodeDecl:
|
||||||
return getASTContext().LangOpts.EnableExperimentalAsyncTopLevel &&
|
return getParent()->isAsyncContext();
|
||||||
getParent()->isAsyncContext();
|
|
||||||
case DeclContextKind::AbstractClosureExpr:
|
case DeclContextKind::AbstractClosureExpr:
|
||||||
return cast<AbstractClosureExpr>(this)->isBodyAsync();
|
return cast<AbstractClosureExpr>(this)->isBodyAsync();
|
||||||
case DeclContextKind::AbstractFunctionDecl: {
|
case DeclContextKind::AbstractFunctionDecl: {
|
||||||
|
|||||||
@@ -487,16 +487,15 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
|||||||
Opts.DisableImplicitConcurrencyModuleImport |=
|
Opts.DisableImplicitConcurrencyModuleImport |=
|
||||||
Args.hasArg(OPT_disable_implicit_concurrency_module_import);
|
Args.hasArg(OPT_disable_implicit_concurrency_module_import);
|
||||||
|
|
||||||
Opts.EnableExperimentalAsyncTopLevel |=
|
|
||||||
Args.hasArg(OPT_enable_experimental_async_top_level);
|
|
||||||
|
|
||||||
/// experimental distributed also implicitly enables experimental concurrency
|
/// experimental distributed also implicitly enables experimental concurrency
|
||||||
Opts.EnableExperimentalDistributed |=
|
Opts.EnableExperimentalDistributed |=
|
||||||
Args.hasArg(OPT_enable_experimental_distributed);
|
Args.hasArg(OPT_enable_experimental_distributed);
|
||||||
Opts.EnableExperimentalConcurrency |=
|
Opts.EnableExperimentalConcurrency |=
|
||||||
Args.hasArg(OPT_enable_experimental_distributed);
|
Args.hasArg(OPT_enable_experimental_distributed);
|
||||||
Opts.EnableExperimentalConcurrency |=
|
|
||||||
Args.hasArg(OPT_enable_experimental_async_top_level);
|
if (Args.hasArg(OPT_enable_experimental_async_top_level))
|
||||||
|
Diags.diagnose(SourceLoc(), diag::warn_flag_deprecated,
|
||||||
|
"-enable-experimental-async-top-level");
|
||||||
|
|
||||||
Opts.DiagnoseInvalidEphemeralnessAsError |=
|
Opts.DiagnoseInvalidEphemeralnessAsError |=
|
||||||
Args.hasArg(OPT_enable_invalid_ephemeralness_as_error);
|
Args.hasArg(OPT_enable_invalid_ephemeralness_as_error);
|
||||||
|
|||||||
@@ -344,14 +344,14 @@ GlobalActorAttributeRequest::evaluate(
|
|||||||
if (auto var = dyn_cast<VarDecl>(storage)) {
|
if (auto var = dyn_cast<VarDecl>(storage)) {
|
||||||
|
|
||||||
// ... but not if it's an async-context top-level global
|
// ... but not if it's an async-context top-level global
|
||||||
if (var->getASTContext().LangOpts.EnableExperimentalAsyncTopLevel &&
|
if (var->isTopLevelGlobal() &&
|
||||||
var->isTopLevelGlobal() && (var->getDeclContext()->isAsyncContext()
|
(var->getDeclContext()->isAsyncContext() ||
|
||||||
|| var->getASTContext().LangOpts.WarnConcurrency)) {
|
var->getASTContext().LangOpts.WarnConcurrency)) {
|
||||||
var->diagnose(diag::global_actor_top_level_var)
|
var->diagnose(diag::global_actor_top_level_var)
|
||||||
.highlight(globalActorAttr->getRangeWithAt());
|
.highlight(globalActorAttr->getRangeWithAt());
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ... and not if it's local property
|
// ... and not if it's local property
|
||||||
if (var->getDeclContext()->isLocalContext()) {
|
if (var->getDeclContext()->isLocalContext()) {
|
||||||
var->diagnose(diag::global_actor_on_local_variable, var->getName())
|
var->diagnose(diag::global_actor_on_local_variable, var->getName())
|
||||||
@@ -3869,8 +3869,7 @@ ActorIsolation ActorIsolationRequest::evaluate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (auto var = dyn_cast<VarDecl>(value)) {
|
if (auto var = dyn_cast<VarDecl>(value)) {
|
||||||
if (var->getASTContext().LangOpts.EnableExperimentalAsyncTopLevel &&
|
if (var->isTopLevelGlobal() &&
|
||||||
var->isTopLevelGlobal() &&
|
|
||||||
(var->getASTContext().LangOpts.WarnConcurrency ||
|
(var->getASTContext().LangOpts.WarnConcurrency ||
|
||||||
var->getDeclContext()->isAsyncContext())) {
|
var->getDeclContext()->isAsyncContext())) {
|
||||||
if (Type mainActor = var->getASTContext().getMainActorType())
|
if (Type mainActor = var->getASTContext().getMainActorType())
|
||||||
|
|||||||
Reference in New Issue
Block a user