Skip to content

Commit af01ed4

Browse files
authored
Merge pull request #80982 from xedin/rdar-145776322-6.2
[6.2][Frontend] Promote `AsyncCallerExecution` to an upcoming feature
2 parents 36d67e9 + d007d7a commit af01ed4

18 files changed

+94
-97
lines changed

include/swift/AST/DiagnosticGroups.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
GROUP(no_group, "")
4242

4343
GROUP(ActorIsolatedCall, "actor-isolated-call")
44-
GROUP(AsyncCallerExecution, "async-caller-execution")
44+
GROUP(NonisolatedNonsendingByDefault, "nonisolated-nonsending-by-default")
4545
GROUP(ConformanceIsolation, "conformance-isolation")
4646
GROUP(DeprecatedDeclaration, "deprecated-declaration")
4747
GROUP(DynamicCallable, "dynamic-callable-requirements")

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8592,22 +8592,22 @@ NOTE(type_does_not_conform_to_Sendable,none,
85928592
"type %0 does not conform to 'Sendable' protocol", (Type))
85938593

85948594
GROUPED_WARNING(
8595-
attr_execution_nonisolated_behavior_will_change_decl, AsyncCallerExecution,
8595+
attr_execution_nonisolated_behavior_will_change_decl, NonisolatedNonsendingByDefault,
85968596
none,
85978597
"feature '%0' will cause nonisolated async %kindbase1 to run on the "
85988598
"caller's actor; use %2 to preserve behavior",
85998599
(StringRef, const AbstractFunctionDecl *, DeclAttribute))
86008600

86018601
GROUPED_WARNING(
86028602
attr_execution_nonisolated_behavior_will_change_closure,
8603-
AsyncCallerExecution, none,
8603+
NonisolatedNonsendingByDefault, none,
86048604
"feature '%0' will cause nonisolated async closure to run on the caller's "
86058605
"actor; use %1 to preserve behavior",
86068606
(StringRef, DeclAttribute))
86078607

86088608
GROUPED_WARNING(
86098609
attr_execution_nonisolated_behavior_will_change_typerepr,
8610-
AsyncCallerExecution, none,
8610+
NonisolatedNonsendingByDefault, none,
86118611
"feature '%0' will cause nonisolated async function type to be treated as "
86128612
"specified to run on the caller's actor; use %1 to preserve "
86138613
"behavior",

include/swift/Basic/Features.def

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ ADOPTABLE_UPCOMING_FEATURE(ExistentialAny, 335, 7)
279279
UPCOMING_FEATURE(InternalImportsByDefault, 409, 7)
280280
UPCOMING_FEATURE(MemberImportVisibility, 444, 7)
281281
UPCOMING_FEATURE(InferIsolatedConformances, 470, 7)
282+
ADOPTABLE_UPCOMING_FEATURE(NonisolatedNonsendingByDefault, 461, 7)
282283

283284
// Optional language features / modes
284285

@@ -487,10 +488,6 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(AddressableTypes, true)
487488
/// Allow the @abi attribute.
488489
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ABIAttribute, true)
489490

490-
/// Functions with nonisolated isolation inherit their isolation from the
491-
/// calling context.
492-
ADOPTABLE_EXPERIMENTAL_FEATURE(AsyncCallerExecution, false)
493-
494491
/// Allow custom availability domains to be defined and referenced.
495492
EXPERIMENTAL_FEATURE(CustomAvailability, true)
496493

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ UNINTERESTING_FEATURE(Volatile)
123123
UNINTERESTING_FEATURE(SuppressedAssociatedTypes)
124124
UNINTERESTING_FEATURE(StructLetDestructuring)
125125
UNINTERESTING_FEATURE(MacrosOnImports)
126-
UNINTERESTING_FEATURE(AsyncCallerExecution)
127126
UNINTERESTING_FEATURE(ExtensibleEnums)
127+
UNINTERESTING_FEATURE(NonisolatedNonsendingByDefault)
128128
UNINTERESTING_FEATURE(KeyPathWithMethodMembers)
129129

130130
static bool usesFeatureNonescapableTypes(Decl *decl) {

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ class DestructureInputs {
17051705
}
17061706

17071707
// If we are an async function that is unspecified or nonisolated, insert an
1708-
// isolated parameter if AsyncCallerExecution is enabled.
1708+
// isolated parameter if NonisolatedNonsendingByDefault is enabled.
17091709
//
17101710
// NOTE: The parameter is not inserted for async functions imported
17111711
// from ObjC because they are handled in a special way that doesn't

lib/Sema/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
add_swift_host_library(swiftSema STATIC
33
AssociatedTypeInference.cpp
4-
AsyncCallerExecutionMigration.cpp
4+
NonisolatedNonsendingByDefaultMigration.cpp
55
BuilderTransform.cpp
66
Comment.cpp
77
CSApply.cpp

lib/Sema/AsyncCallerExecutionMigration.cpp renamed to lib/Sema/NonisolatedNonsendingByDefaultMigration.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- Sema/AsyncCallerExecutionMigration.cpp ------------------*- C++ -*-===//
1+
//===-- Sema/NonisolatedNonsendingByDefaultMigration.cpp --------*- C++ -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -11,12 +11,12 @@
1111
//===----------------------------------------------------------------------===//
1212
///
1313
/// \file
14-
/// This file implements code migration support for the `AsyncCallerExecution`
15-
/// feature.
14+
/// This file implements code migration support for the
15+
/// `NonisolatedNonsendingByDefault` feature.
1616
///
1717
//===----------------------------------------------------------------------===//
1818

19-
#include "AsyncCallerExecutionMigration.h"
19+
#include "NonisolatedNonsendingByDefaultMigration.h"
2020
#include "swift/AST/ASTContext.h"
2121
#include "swift/AST/Decl.h"
2222
#include "swift/AST/DiagnosticsSema.h"
@@ -30,34 +30,34 @@
3030
using namespace swift;
3131

3232
namespace {
33-
class AsyncCallerExecutionMigrationTarget {
33+
class NonisolatedNonsendingByDefaultMigrationTarget {
3434
ASTContext &ctx;
3535
PointerUnion<ValueDecl *, AbstractClosureExpr *, FunctionTypeRepr *> node;
3636
TaggedUnion<ActorIsolation, FunctionTypeIsolation> isolation;
3737

3838
public:
39-
AsyncCallerExecutionMigrationTarget(ASTContext &ctx, ValueDecl *decl,
39+
NonisolatedNonsendingByDefaultMigrationTarget(ASTContext &ctx, ValueDecl *decl,
4040
ActorIsolation isolation)
4141
: ctx(ctx), node(decl), isolation(isolation) {}
4242

43-
AsyncCallerExecutionMigrationTarget(ASTContext &ctx,
43+
NonisolatedNonsendingByDefaultMigrationTarget(ASTContext &ctx,
4444
AbstractClosureExpr *closure,
4545
ActorIsolation isolation)
4646
: ctx(ctx), node(closure), isolation(isolation) {}
4747

48-
AsyncCallerExecutionMigrationTarget(ASTContext &ctx, FunctionTypeRepr *repr,
48+
NonisolatedNonsendingByDefaultMigrationTarget(ASTContext &ctx, FunctionTypeRepr *repr,
4949
FunctionTypeIsolation isolation)
5050
: ctx(ctx), node(repr), isolation(isolation) {}
5151

5252
/// Warns that the behavior of nonisolated async functions will change under
53-
/// `AsyncCallerExecution` and suggests `@concurrent` to preserve the current
53+
/// `NonisolatedNonsendingByDefault` and suggests `@concurrent` to preserve the current
5454
/// behavior.
5555
void diagnose() const;
5656
};
5757
} // end anonymous namespace
5858

59-
void AsyncCallerExecutionMigrationTarget::diagnose() const {
60-
const auto feature = Feature::AsyncCallerExecution;
59+
void NonisolatedNonsendingByDefaultMigrationTarget::diagnose() const {
60+
const auto feature = Feature::NonisolatedNonsendingByDefault;
6161

6262
ASSERT(node);
6363
ASSERT(ctx.LangOpts.getFeatureState(feature).isEnabledForAdoption());
@@ -189,15 +189,15 @@ void AsyncCallerExecutionMigrationTarget::diagnose() const {
189189

190190
void swift::warnAboutNewNonisolatedAsyncExecutionBehavior(
191191
ASTContext &ctx, FunctionTypeRepr *repr, FunctionTypeIsolation isolation) {
192-
AsyncCallerExecutionMigrationTarget(ctx, repr, isolation).diagnose();
192+
NonisolatedNonsendingByDefaultMigrationTarget(ctx, repr, isolation).diagnose();
193193
}
194194

195195
void swift::warnAboutNewNonisolatedAsyncExecutionBehavior(
196196
ASTContext &ctx, ValueDecl *decl, ActorIsolation isolation) {
197-
AsyncCallerExecutionMigrationTarget(ctx, decl, isolation).diagnose();
197+
NonisolatedNonsendingByDefaultMigrationTarget(ctx, decl, isolation).diagnose();
198198
}
199199

200200
void swift::warnAboutNewNonisolatedAsyncExecutionBehavior(
201201
ASTContext &ctx, AbstractClosureExpr *closure, ActorIsolation isolation) {
202-
AsyncCallerExecutionMigrationTarget(ctx, closure, isolation).diagnose();
202+
NonisolatedNonsendingByDefaultMigrationTarget(ctx, closure, isolation).diagnose();
203203
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===-- Sema/AsyncCallerExecutionMigration.h --------------------*- C++ -*-===//
1+
//===-- Sema/NonisolatedNonsendingByDefaultMigration.h ----------*- C++ -*-===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
@@ -11,13 +11,13 @@
1111
//===----------------------------------------------------------------------===//
1212
///
1313
/// \file
14-
/// This file provides code migration support for the `AsyncCallerExecution`
15-
/// feature.
14+
/// This file provides code migration support for the
15+
/// `NonisolatedNonsendingByDefault` feature.
1616
///
1717
//===----------------------------------------------------------------------===//
1818

19-
#ifndef SWIFT_SEMA_ASYNCCALLEREXECUTIONMIGRATION_H
20-
#define SWIFT_SEMA_ASYNCCALLEREXECUTIONMIGRATION_H
19+
#ifndef SWIFT_SEMA_NONISOLATEDNONSENDINGBYDEFAULTMIGRATION_H
20+
#define SWIFT_SEMA_NONISOLATEDNONSENDINGBYDEFAULTMIGRATION_H
2121

2222
#include "swift/AST/ActorIsolation.h"
2323
#include "swift/AST/ExtInfo.h"
@@ -29,25 +29,25 @@ class ValueDecl;
2929
class AbstractClosureExpr;
3030

3131
/// Warns that the behavior of nonisolated async functions will change under
32-
/// `AsyncCallerExecution` and suggests `@concurrent` to preserve the current
32+
/// `NonisolatedNonsendingByDefault` and suggests `@concurrent` to preserve the current
3333
/// behavior.
3434
void warnAboutNewNonisolatedAsyncExecutionBehavior(
3535
ASTContext &ctx, FunctionTypeRepr *node, FunctionTypeIsolation isolation);
3636

3737
/// Warns that the behavior of nonisolated async functions will change under
38-
/// `AsyncCallerExecution` and suggests `@concurrent` to preserve the current
38+
/// `NonisolatedNonsendingByDefault` and suggests `@concurrent` to preserve the current
3939
/// behavior.
4040
void warnAboutNewNonisolatedAsyncExecutionBehavior(ASTContext &ctx,
4141
ValueDecl *node,
4242
ActorIsolation isolation);
4343

4444
/// Warns that the behavior of nonisolated async functions will change under
45-
/// `AsyncCallerExecution` and suggests `@concurrent` to preserve the current
45+
/// `NonisolatedNonsendingByDefault` and suggests `@concurrent` to preserve the current
4646
/// behavior.
4747
void warnAboutNewNonisolatedAsyncExecutionBehavior(ASTContext &ctx,
4848
AbstractClosureExpr *node,
4949
ActorIsolation isolation);
5050

5151
} // end namespace swift
5252

53-
#endif /* SWIFT_SEMA_ASYNCCALLEREXECUTIONMIGRATION_H */
53+
#endif /* SWIFT_SEMA_NONISOLATEDNONSENDINGBYDEFAULTMIGRATION_H */

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//===----------------------------------------------------------------------===//
1616

1717
#include "TypeCheckConcurrency.h"
18-
#include "AsyncCallerExecutionMigration.h"
18+
#include "NonisolatedNonsendingByDefaultMigration.h"
1919
#include "MiscDiagnostics.h"
2020
#include "TypeCheckDistributed.h"
2121
#include "TypeCheckInvertible.h"
@@ -4767,7 +4767,7 @@ ActorIsolation ActorIsolationChecker::determineClosureIsolation(
47674767
// Apply computed preconcurrency.
47684768
isolation = isolation.withPreconcurrency(preconcurrency);
47694769

4770-
if (ctx.LangOpts.getFeatureState(Feature::AsyncCallerExecution)
4770+
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
47714771
.isEnabledForAdoption()) {
47724772
warnAboutNewNonisolatedAsyncExecutionBehavior(ctx, closure, isolation);
47734773
}
@@ -4948,7 +4948,7 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
49484948
// If the nonisolated async inherits isolation from context,
49494949
// return caller isolation inheriting.
49504950
if (decl->getASTContext().LangOpts.hasFeature(
4951-
Feature::AsyncCallerExecution)) {
4951+
Feature::NonisolatedNonsendingByDefault)) {
49524952
if (auto *func = dyn_cast<AbstractFunctionDecl>(decl);
49534953
func && func->hasAsync() &&
49544954
func->getModuleContext() == decl->getASTContext().MainModule) {
@@ -5814,7 +5814,7 @@ computeDefaultInferredActorIsolation(ValueDecl *value) {
58145814
}
58155815

58165816
// If we have an async function... by default we inherit isolation.
5817-
if (ctx.LangOpts.hasFeature(Feature::AsyncCallerExecution)) {
5817+
if (ctx.LangOpts.hasFeature(Feature::NonisolatedNonsendingByDefault)) {
58185818
if (auto *func = dyn_cast<AbstractFunctionDecl>(value);
58195819
func && func->hasAsync() &&
58205820
func->getModuleContext() == ctx.MainModule) {
@@ -5931,7 +5931,7 @@ static InferredActorIsolation computeActorIsolation(Evaluator &evaluator,
59315931
// did not have an ExecutionKind::Caller attached to it.
59325932
//
59335933
// DISCUSSION: This occurs when we have a value decl that is explicitly marked
5934-
// as nonisolated but since AsyncCallerExecution is enabled, we return
5934+
// as nonisolated but since NonisolatedNonsendingByDefault is enabled, we return
59355935
// CallerIsolationInheriting.
59365936
if (isolationFromAttr && isolationFromAttr->getKind() ==
59375937
ActorIsolation::CallerIsolationInheriting) {
@@ -6232,7 +6232,7 @@ static InferredActorIsolation computeActorIsolation(Evaluator &evaluator,
62326232

62336233
if (auto *func = dyn_cast<AbstractFunctionDecl>(value);
62346234
ctx.LangOpts.hasFeature(
6235-
Feature::AsyncCallerExecution) &&
6235+
Feature::NonisolatedNonsendingByDefault) &&
62366236
func && func->hasAsync() &&
62376237
func->getModuleContext() == ctx.MainModule &&
62386238
isolation.isNonisolated()) {
@@ -6277,7 +6277,7 @@ InferredActorIsolation ActorIsolationRequest::evaluate(Evaluator &evaluator,
62776277
const auto inferredIsolation = computeActorIsolation(evaluator, value);
62786278

62796279
auto &ctx = value->getASTContext();
6280-
if (ctx.LangOpts.getFeatureState(Feature::AsyncCallerExecution)
6280+
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
62816281
.isEnabledForAdoption()) {
62826282
warnAboutNewNonisolatedAsyncExecutionBehavior(ctx, value,
62836283
inferredIsolation.isolation);

lib/Sema/TypeCheckType.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
//===----------------------------------------------------------------------===//
1717

1818
#include "TypeCheckType.h"
19-
#include "AsyncCallerExecutionMigration.h"
19+
#include "NonisolatedNonsendingByDefaultMigration.h"
2020
#include "TypeCheckAvailability.h"
2121
#include "TypeCheckConcurrency.h"
2222
#include "TypeCheckInvertible.h"
@@ -4251,7 +4251,7 @@ NeverNullType TypeResolver::resolveASTFunctionType(
42514251
if (!repr->isInvalid())
42524252
isolation = FunctionTypeIsolation::forNonIsolated();
42534253
} else {
4254-
if (ctx.LangOpts.getFeatureState(Feature::AsyncCallerExecution)
4254+
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
42554255
.isEnabledForAdoption()) {
42564256
// Diagnose only in the interface stage, which is run once.
42574257
if (inStage(TypeResolutionStage::Interface)) {

0 commit comments

Comments
 (0)