Skip to content

Commit c45fa0c

Browse files
authored
Merge pull request #80969 from xedin/rdar-145776322
[Frontend] Promote `AsyncCallerExecution` to an upcoming feature
2 parents 3547ba5 + c110941 commit c45fa0c

19 files changed

+95
-98
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
@@ -8643,22 +8643,22 @@ NOTE(type_does_not_conform_to_Sendable,none,
86438643
"type %0 does not conform to 'Sendable' protocol", (Type))
86448644

86458645
GROUPED_WARNING(
8646-
attr_execution_nonisolated_behavior_will_change_decl, AsyncCallerExecution,
8646+
attr_execution_nonisolated_behavior_will_change_decl, NonisolatedNonsendingByDefault,
86478647
none,
86488648
"feature '%0' will cause nonisolated async %kindbase1 to run on the "
86498649
"caller's actor; use %2 to preserve behavior",
86508650
(StringRef, const AbstractFunctionDecl *, DeclAttribute))
86518651

86528652
GROUPED_WARNING(
86538653
attr_execution_nonisolated_behavior_will_change_closure,
8654-
AsyncCallerExecution, none,
8654+
NonisolatedNonsendingByDefault, none,
86558655
"feature '%0' will cause nonisolated async closure to run on the caller's "
86568656
"actor; use %1 to preserve behavior",
86578657
(StringRef, DeclAttribute))
86588658

86598659
GROUPED_WARNING(
86608660
attr_execution_nonisolated_behavior_will_change_typerepr,
8661-
AsyncCallerExecution, none,
8661+
NonisolatedNonsendingByDefault, none,
86628662
"feature '%0' will cause nonisolated async function type to be treated as "
86638663
"specified to run on the caller's actor; use %1 to preserve "
86648664
"behavior",

include/swift/Basic/Features.def

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

284285
// Optional language features / modes
285286

@@ -489,10 +490,6 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(AddressableTypes, true)
489490
/// Allow the @abi attribute.
490491
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(ABIAttribute, true)
491492

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

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ UNINTERESTING_FEATURE(Volatile)
124124
UNINTERESTING_FEATURE(SuppressedAssociatedTypes)
125125
UNINTERESTING_FEATURE(StructLetDestructuring)
126126
UNINTERESTING_FEATURE(MacrosOnImports)
127-
UNINTERESTING_FEATURE(AsyncCallerExecution)
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"
@@ -4764,7 +4764,7 @@ ActorIsolation ActorIsolationChecker::determineClosureIsolation(
47644764
// Apply computed preconcurrency.
47654765
isolation = isolation.withPreconcurrency(preconcurrency);
47664766

4767-
if (ctx.LangOpts.getFeatureState(Feature::AsyncCallerExecution)
4767+
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
47684768
.isEnabledForAdoption()) {
47694769
warnAboutNewNonisolatedAsyncExecutionBehavior(ctx, closure, isolation);
47704770
}
@@ -4945,7 +4945,7 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
49454945
// If the nonisolated async inherits isolation from context,
49464946
// return caller isolation inheriting.
49474947
if (decl->getASTContext().LangOpts.hasFeature(
4948-
Feature::AsyncCallerExecution)) {
4948+
Feature::NonisolatedNonsendingByDefault)) {
49494949
if (auto *func = dyn_cast<AbstractFunctionDecl>(decl);
49504950
func && func->hasAsync() &&
49514951
func->getModuleContext() == decl->getASTContext().MainModule) {
@@ -5809,7 +5809,7 @@ computeDefaultInferredActorIsolation(ValueDecl *value) {
58095809
}
58105810

58115811
// If we have an async function... by default we inherit isolation.
5812-
if (ctx.LangOpts.hasFeature(Feature::AsyncCallerExecution)) {
5812+
if (ctx.LangOpts.hasFeature(Feature::NonisolatedNonsendingByDefault)) {
58135813
if (auto *func = dyn_cast<AbstractFunctionDecl>(value);
58145814
func && func->hasAsync() &&
58155815
func->getModuleContext() == ctx.MainModule) {
@@ -5926,7 +5926,7 @@ static InferredActorIsolation computeActorIsolation(Evaluator &evaluator,
59265926
// did not have an ExecutionKind::Caller attached to it.
59275927
//
59285928
// DISCUSSION: This occurs when we have a value decl that is explicitly marked
5929-
// as nonisolated but since AsyncCallerExecution is enabled, we return
5929+
// as nonisolated but since NonisolatedNonsendingByDefault is enabled, we return
59305930
// CallerIsolationInheriting.
59315931
if (isolationFromAttr && isolationFromAttr->getKind() ==
59325932
ActorIsolation::CallerIsolationInheriting) {
@@ -6227,7 +6227,7 @@ static InferredActorIsolation computeActorIsolation(Evaluator &evaluator,
62276227

62286228
if (auto *func = dyn_cast<AbstractFunctionDecl>(value);
62296229
ctx.LangOpts.hasFeature(
6230-
Feature::AsyncCallerExecution) &&
6230+
Feature::NonisolatedNonsendingByDefault) &&
62316231
func && func->hasAsync() &&
62326232
func->getModuleContext() == ctx.MainModule &&
62336233
isolation.isNonisolated()) {
@@ -6272,7 +6272,7 @@ InferredActorIsolation ActorIsolationRequest::evaluate(Evaluator &evaluator,
62726272
const auto inferredIsolation = computeActorIsolation(evaluator, value);
62736273

62746274
auto &ctx = value->getASTContext();
6275-
if (ctx.LangOpts.getFeatureState(Feature::AsyncCallerExecution)
6275+
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
62766276
.isEnabledForAdoption()) {
62776277
warnAboutNewNonisolatedAsyncExecutionBehavior(ctx, value,
62786278
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"
@@ -4245,7 +4245,7 @@ NeverNullType TypeResolver::resolveASTFunctionType(
42454245
if (!repr->isInvalid())
42464246
isolation = FunctionTypeIsolation::forNonIsolated();
42474247
} else {
4248-
if (ctx.LangOpts.getFeatureState(Feature::AsyncCallerExecution)
4248+
if (ctx.LangOpts.getFeatureState(Feature::NonisolatedNonsendingByDefault)
42494249
.isEnabledForAdoption()) {
42504250
// Diagnose only in the interface stage, which is run once.
42514251
if (inStage(TypeResolutionStage::Interface)) {

test/Concurrency/Runtime/nonisolated_inherits_isolation.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// RUN: %target-run-simple-swift( -swift-version 6 -g %import-libdispatch -import-objc-header %S/Inputs/RunOnMainActor.h -enable-experimental-feature AsyncCallerExecution )
1+
// RUN: %target-run-simple-swift( -swift-version 6 -g %import-libdispatch -import-objc-header %S/Inputs/RunOnMainActor.h -enable-upcoming-feature NonisolatedNonsendingByDefault )
22

33
// REQUIRES: executable_test
44
// REQUIRES: concurrency
55
// REQUIRES: concurrency_runtime
66
// REQUIRES: libdispatch
77
// REQUIRES: asserts
88

9-
// REQUIRES: swift_feature_AsyncCallerExecution
9+
// REQUIRES: swift_feature_NonisolatedNonsendingByDefault
1010

1111
// UNSUPPORTED: freestanding
1212

0 commit comments

Comments
 (0)