Skip to content

Commit 76c4ac8

Browse files
committed
Add a temporary flag to stage in back-deployment of concurrency.
Add a frontend-only flag `-enable-experimental-back-deploy-concurrency` to be used to stage in the back deployment of concurrency. At present, all it does is lower the availability minimums for use of concurrency features.
1 parent 474eafd commit 76c4ac8

File tree

7 files changed

+33
-1
lines changed

7 files changed

+33
-1
lines changed

include/swift/AST/ASTContext.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,9 @@ class ASTContext final {
738738
/// Get the runtime availability of support for concurrency.
739739
AvailabilityContext getConcurrencyAvailability();
740740

741+
/// Get the back-deployed availability for concurrency.
742+
AvailabilityContext getBackDeployedConcurrencyAvailability();
743+
741744
/// Get the runtime availability of support for differentiation.
742745
AvailabilityContext getDifferentiationAvailability();
743746

include/swift/Basic/LangOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,9 @@ namespace swift {
301301
/// Enable experimental concurrency model.
302302
bool EnableExperimentalConcurrency = false;
303303

304+
/// Enable experimental back-deployment of the concurrency model.
305+
bool EnableExperimentalBackDeployConcurrency = false;
306+
304307
/// Enable experimental support for named opaque result types, e.g.
305308
/// `func f() -> <T> T`.
306309
bool EnableExperimentalNamedOpaqueTypes = false;

include/swift/Option/FrontendOptions.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ def enable_experimental_concurrency :
247247
Flag<["-"], "enable-experimental-concurrency">,
248248
HelpText<"Enable experimental concurrency model">;
249249

250+
def enable_experimental_back_deploy_concurrency :
251+
Flag<["-"], "enable-experimental-back-deploy-concurrency">,
252+
HelpText<"Enable experimental back-deployment of the concurrency model">;
253+
250254
def enable_experimental_distributed :
251255
Flag<["-"], "enable-experimental-distributed">,
252256
HelpText<"Enable experimental 'distributed' actors and functions">;

lib/AST/Availability.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,10 @@ AvailabilityContext ASTContext::getConcurrencyAvailability() {
330330
return getSwift55Availability();
331331
}
332332

333+
AvailabilityContext ASTContext::getBackDeployedConcurrencyAvailability() {
334+
return getSwift51Availability();
335+
}
336+
333337
AvailabilityContext ASTContext::getDifferentiationAvailability() {
334338
return getSwiftFutureAvailability();
335339
}

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,9 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
422422
Opts.EnableExperimentalConcurrency |=
423423
Args.hasArg(OPT_enable_experimental_concurrency);
424424

425+
Opts.EnableExperimentalBackDeployConcurrency |=
426+
Args.hasArg(OPT_enable_experimental_back_deploy_concurrency);
427+
425428
Opts.EnableExperimentalNamedOpaqueTypes |=
426429
Args.hasArg(OPT_enable_experimental_named_opaque_types);
427430

lib/Sema/TypeCheckAvailability.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,9 @@ void TypeChecker::checkConcurrencyAvailability(SourceRange ReferenceRange,
16941694
auto runningOS =
16951695
TypeChecker::overApproximateAvailabilityAtLocation(
16961696
ReferenceRange.Start, ReferenceDC);
1697-
auto availability = ctx.getConcurrencyAvailability();
1697+
auto availability = ctx.LangOpts.EnableExperimentalBackDeployConcurrency
1698+
? ctx.getBackDeployedConcurrencyAvailability()
1699+
: ctx.getConcurrencyAvailability();
16981700
if (!runningOS.isContainedIn(availability)) {
16991701
diagnosePotentialConcurrencyUnavailability(
17001702
ReferenceRange, ReferenceDC,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-swift-frontend -parse-stdlib -target x86_64-apple-macosx10.13 -typecheck -verify -enable-experimental-back-deploy-concurrency %s
2+
// RUN: %target-swift-frontend -parse-stdlib -target x86_64-apple-macosx10.15 -typecheck -enable-experimental-back-deploy-concurrency %s
3+
// REQUIRES: OS=macosx
4+
5+
func f() async { } // expected-error{{concurrency is only available in}}
6+
// expected-note@-1{{add @available}}
7+
8+
actor A { } // expected-error{{concurrency is only available in}}
9+
// expected-note@-1{{add @available}}
10+
11+
// Allow this without any availability for Historical Reasons.
12+
public func swift_deletedAsyncMethodError() async {
13+
}

0 commit comments

Comments
 (0)