Skip to content

Add a temporary flag to stage in back-deployment of concurrency. #39044

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/swift/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,9 @@ class ASTContext final {
/// Get the runtime availability of support for concurrency.
AvailabilityContext getConcurrencyAvailability();

/// Get the back-deployed availability for concurrency.
AvailabilityContext getBackDeployedConcurrencyAvailability();

/// Get the runtime availability of support for differentiation.
AvailabilityContext getDifferentiationAvailability();

Expand Down
3 changes: 3 additions & 0 deletions include/swift/Basic/LangOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,9 @@ namespace swift {
/// Enable experimental concurrency model.
bool EnableExperimentalConcurrency = false;

/// Enable experimental back-deployment of the concurrency model.
bool EnableExperimentalBackDeployConcurrency = false;

/// Enable experimental support for named opaque result types, e.g.
/// `func f() -> <T> T`.
bool EnableExperimentalNamedOpaqueTypes = false;
Expand Down
4 changes: 4 additions & 0 deletions include/swift/Option/FrontendOptions.td
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ def enable_experimental_concurrency :
Flag<["-"], "enable-experimental-concurrency">,
HelpText<"Enable experimental concurrency model">;

def enable_experimental_back_deploy_concurrency :
Flag<["-"], "enable-experimental-back-deploy-concurrency">,
HelpText<"Enable experimental back-deployment of the concurrency model">;

def enable_experimental_distributed :
Flag<["-"], "enable-experimental-distributed">,
HelpText<"Enable experimental 'distributed' actors and functions">;
Expand Down
4 changes: 4 additions & 0 deletions lib/AST/Availability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ AvailabilityContext ASTContext::getConcurrencyAvailability() {
return getSwift55Availability();
}

AvailabilityContext ASTContext::getBackDeployedConcurrencyAvailability() {
return getSwift51Availability();
}

AvailabilityContext ASTContext::getDifferentiationAvailability() {
return getSwiftFutureAvailability();
}
Expand Down
3 changes: 3 additions & 0 deletions lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
Opts.EnableExperimentalConcurrency |=
Args.hasArg(OPT_enable_experimental_concurrency);

Opts.EnableExperimentalBackDeployConcurrency |=
Args.hasArg(OPT_enable_experimental_back_deploy_concurrency);

Opts.EnableExperimentalNamedOpaqueTypes |=
Args.hasArg(OPT_enable_experimental_named_opaque_types);

Expand Down
4 changes: 3 additions & 1 deletion lib/Sema/TypeCheckAvailability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1694,7 +1694,9 @@ void TypeChecker::checkConcurrencyAvailability(SourceRange ReferenceRange,
auto runningOS =
TypeChecker::overApproximateAvailabilityAtLocation(
ReferenceRange.Start, ReferenceDC);
auto availability = ctx.getConcurrencyAvailability();
auto availability = ctx.LangOpts.EnableExperimentalBackDeployConcurrency
? ctx.getBackDeployedConcurrencyAvailability()
: ctx.getConcurrencyAvailability();
if (!runningOS.isContainedIn(availability)) {
diagnosePotentialConcurrencyUnavailability(
ReferenceRange, ReferenceDC,
Expand Down
13 changes: 13 additions & 0 deletions test/Concurrency/concurrency_availability_back_deploy.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: %target-swift-frontend -parse-stdlib -target x86_64-apple-macosx10.13 -typecheck -verify -enable-experimental-back-deploy-concurrency %s
// RUN: %target-swift-frontend -parse-stdlib -target x86_64-apple-macosx10.15 -typecheck -enable-experimental-back-deploy-concurrency %s
// REQUIRES: OS=macosx

func f() async { } // expected-error{{concurrency is only available in}}
// expected-note@-1{{add @available}}

actor A { } // expected-error{{concurrency is only available in}}
// expected-note@-1{{add @available}}

// Allow this without any availability for Historical Reasons.
public func swift_deletedAsyncMethodError() async {
}