Skip to content

Commit 2074057

Browse files
authored
Merge pull request #37415 from DougGregor/remove-asynchandler
2 parents e0eff48 + 2b9ca31 commit 2074057

39 files changed

+33
-713
lines changed

include/swift/AST/ASTMangler.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class ASTMangler : public Mangler {
8585
public:
8686
enum class SymbolKind {
8787
Default,
88-
AsyncHandlerBody,
8988
DynamicThunk,
9089
SwiftAsObjCThunk,
9190
ObjCAsSwiftThunk,
@@ -347,7 +346,6 @@ class ASTMangler : public Mangler {
347346
enum FunctionManglingKind {
348347
NoFunctionMangling,
349348
FunctionMangling,
350-
AsyncHandlerBodyMangling
351349
};
352350

353351
void appendFunction(AnyFunctionType *fn,
@@ -433,7 +431,7 @@ class ASTMangler : public Mangler {
433431

434432
void appendEntity(const ValueDecl *decl, StringRef EntityOp, bool isStatic);
435433

436-
void appendEntity(const ValueDecl *decl, bool isAsyncHandlerBody = false);
434+
void appendEntity(const ValueDecl *decl);
437435

438436
void appendProtocolConformance(const ProtocolConformance *conformance);
439437
void appendProtocolConformanceRef(const RootProtocolConformance *conformance);

include/swift/AST/Attr.def

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,10 +565,7 @@ SIMPLE_DECL_ATTR(noDerivative, NoDerivative,
565565
ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove,
566566
100)
567567

568-
SIMPLE_DECL_ATTR(asyncHandler, AsyncHandler,
569-
OnFunc | ConcurrencyOnly |
570-
ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove,
571-
101)
568+
// 101 was @asyncHandler and is now unused
572569

573570
// TODO: Remove this once we don't need to support 'actor' as a modifier
574571
CONTEXTUAL_SIMPLE_DECL_ATTR(actor, Actor,

include/swift/AST/Decl.h

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ class alignas(1 << DeclAlignInBits) Decl {
423423
HasNestedTypeDeclarations : 1
424424
);
425425

426-
SWIFT_INLINE_BITFIELD(FuncDecl, AbstractFunctionDecl, 1+1+2+1+1+2+1+1+1,
426+
SWIFT_INLINE_BITFIELD(FuncDecl, AbstractFunctionDecl, 1+1+2+1+1+2+1,
427427
/// Whether we've computed the 'static' flag yet.
428428
IsStaticComputed : 1,
429429

@@ -442,12 +442,6 @@ class alignas(1 << DeclAlignInBits) Decl {
442442
/// Backing bits for 'self' access kind.
443443
SelfAccess : 2,
444444

445-
/// Whether we've computed the IsAsyncHandlerRequest.
446-
IsAsyncHandlerComputed : 1,
447-
448-
/// The value of IsAsyncHandlerRequest.
449-
IsAsyncHandler : 1,
450-
451445
/// Whether this is a top-level function which should be treated
452446
/// as if it were in local context for the purposes of capture
453447
/// analysis.
@@ -5849,16 +5843,9 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
58495843
///
58505844
/// Functions that are an 'async' context can make calls to 'async' functions.
58515845
bool isAsyncContext() const {
5852-
return hasAsync() || isAsyncHandler();
5846+
return hasAsync();
58535847
}
58545848

5855-
/// Returns true if the function is an @asyncHandler.
5856-
bool isAsyncHandler() const;
5857-
5858-
/// Returns true if the function signature matches the form of an
5859-
/// @asyncHandler.
5860-
bool canBeAsyncHandler() const;
5861-
58625849
/// Returns true if the function body throws.
58635850
bool hasThrows() const { return Bits.AbstractFunctionDecl.Throws; }
58645851

@@ -6143,7 +6130,6 @@ class FuncDecl : public AbstractFunctionDecl {
61436130
friend class SelfAccessKindRequest;
61446131
friend class IsStaticRequest;
61456132
friend class ResultTypeRequest;
6146-
friend class IsAsyncHandlerRequest;
61476133

61486134
SourceLoc StaticLoc; // Location of the 'static' token or invalid.
61496135
SourceLoc FuncLoc; // Location of the 'func' token.
@@ -6175,8 +6161,6 @@ class FuncDecl : public AbstractFunctionDecl {
61756161
Bits.FuncDecl.SelfAccessComputed = false;
61766162
Bits.FuncDecl.IsStaticComputed = false;
61776163
Bits.FuncDecl.IsStatic = false;
6178-
Bits.FuncDecl.IsAsyncHandlerComputed = false;
6179-
Bits.FuncDecl.IsAsyncHandler = false;
61806164
Bits.FuncDecl.HasTopLevelLocalContextCaptures = false;
61816165
}
61826166

@@ -6207,18 +6191,6 @@ class FuncDecl : public AbstractFunctionDecl {
62076191
return None;
62086192
}
62096193

6210-
Optional<bool> getCachedIsAsyncHandler() const {
6211-
if (Bits.FuncDecl.IsAsyncHandlerComputed)
6212-
return Bits.FuncDecl.IsAsyncHandler;
6213-
6214-
return None;
6215-
}
6216-
6217-
void setIsAsyncHandler(bool value) {
6218-
Bits.FuncDecl.IsAsyncHandlerComputed = true;
6219-
Bits.FuncDecl.IsAsyncHandler = value;
6220-
}
6221-
62226194
public:
62236195
/// Factory function only for use by deserialization.
62246196
static FuncDecl *createDeserialized(ASTContext &Context,

include/swift/AST/DiagnosticsSema.def

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4299,8 +4299,6 @@ ERROR(async_in_nonasync_function,none,
42994299
(unsigned, bool))
43004300
NOTE(note_add_async_to_function,none,
43014301
"add 'async' to function %0 to make it asynchronous", (DeclName))
4302-
NOTE(note_add_asynchandler_to_function,none,
4303-
"add '@asyncHandler' to function %0 to create an implicit asynchronous context", (DeclName))
43044302
NOTE(note_add_nonisolated_to_decl,none,
43054303
"add 'nonisolated' to %0 to make this %1 not isolated to the actor",
43064304
(DeclName, DescriptiveDeclKind))
@@ -4336,30 +4334,6 @@ ERROR(async_let_in_illegal_context,none,
43364334
"%select{<<ERROR>>|a default argument|a property wrapper initializer|a property initializer|a global variable initializer|an enum case raw value|a catch pattern|a catch guard expression|a defer body}1",
43374335
(DeclName, unsigned))
43384336

4339-
ERROR(asynchandler_non_func,none,
4340-
"'@asyncHandler' can only be applied to functions",
4341-
())
4342-
ERROR(asynchandler_returns_value,none,
4343-
"'@asyncHandler' function can only return 'Void'",
4344-
())
4345-
ERROR(asynchandler_throws,none,
4346-
"'@asyncHandler' function cannot throw",
4347-
())
4348-
ERROR(asynchandler_async,none,
4349-
"'@asyncHandler' function cannot be 'async' itself",
4350-
())
4351-
ERROR(asynchandler_inout_parameter,none,
4352-
"'inout' parameter is not allowed in '@asyncHandler' function",
4353-
())
4354-
ERROR(asynchandler_noescape_closure_parameter,none,
4355-
"non-escaping closure parameter is not allowed in '@asyncHandler' function",
4356-
())
4357-
ERROR(asynchandler_mutating,none,
4358-
"'@asyncHandler' function cannot be 'mutating'",
4359-
())
4360-
ERROR(asynchandler_removed,none,
4361-
"'@asyncHandler' has been removed from the language", ())
4362-
43634337
ERROR(objc_ambiguous_async_convention,none,
43644338
"%0 overrides or implements protocol requirements for Objective-C "
43654339
"declarations with incompatible async conventions",

include/swift/AST/TypeCheckRequests.h

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -878,45 +878,6 @@ class SelfAccessKindRequest :
878878
void cacheResult(SelfAccessKind value) const;
879879
};
880880

881-
/// Determine whether the given function is an @asyncHandler.
882-
class IsAsyncHandlerRequest :
883-
public SimpleRequest<IsAsyncHandlerRequest,
884-
bool(FuncDecl *),
885-
RequestFlags::SeparatelyCached> {
886-
public:
887-
using SimpleRequest::SimpleRequest;
888-
889-
private:
890-
friend SimpleRequest;
891-
892-
bool evaluate(Evaluator &evaluator, FuncDecl *func) const;
893-
894-
public:
895-
// Separate caching.
896-
bool isCached() const { return true; }
897-
Optional<bool> getCachedResult() const;
898-
void cacheResult(bool value) const;
899-
};
900-
901-
/// Determine whether the given function can be an @asyncHandler, without
902-
/// producing any diagnostics.
903-
class CanBeAsyncHandlerRequest :
904-
public SimpleRequest<CanBeAsyncHandlerRequest,
905-
bool(FuncDecl *),
906-
RequestFlags::Cached> {
907-
public:
908-
using SimpleRequest::SimpleRequest;
909-
910-
private:
911-
friend SimpleRequest;
912-
913-
bool evaluate(Evaluator &evaluator, FuncDecl *func) const;
914-
915-
public:
916-
// Caching
917-
bool isCached() const { return true; }
918-
};
919-
920881
/// Determine whether the given nominal type is an actor.
921882
class IsActorRequest :
922883
public SimpleRequest<IsActorRequest,

include/swift/AST/TypeCheckerTypeIDZone.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ SWIFT_REQUEST(TypeChecker, ExtendedTypeRequest, Type(ExtensionDecl *), Cached,
9393
NoLocationInfo)
9494
SWIFT_REQUEST(TypeChecker, ResultBuilderTypeRequest, Type(ValueDecl *),
9595
Cached, NoLocationInfo)
96-
SWIFT_REQUEST(TypeChecker, IsAsyncHandlerRequest, bool(FuncDecl *),
97-
Cached, NoLocationInfo)
98-
SWIFT_REQUEST(TypeChecker, CanBeAsyncHandlerRequest, bool(FuncDecl *),
99-
Cached, NoLocationInfo)
10096
SWIFT_REQUEST(TypeChecker, IsActorRequest, bool(NominalTypeDecl *),
10197
Cached, NoLocationInfo)
10298
SWIFT_REQUEST(TypeChecker, IsDefaultActorRequest,

include/swift/Basic/LangOptions.h

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

267-
/// Enable experimental asyncHandler support.
268-
bool EnableExperimentalAsyncHandler = false;
269-
270267
/// Enable experimental flow-sensitive concurrent captures.
271268
bool EnableExperimentalFlowSensitiveConcurrentCaptures = false;
272269

include/swift/Option/FrontendOptions.td

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

229-
def enable_experimental_async_handler :
230-
Flag<["-"], "enable-experimental-async-handler">,
231-
HelpText<"Enable experimental @asyncHandler feature">;
232-
233229
def enable_experimental_flow_sensitive_concurrent_captures :
234230
Flag<["-"], "enable-experimental-flow-sensitive-concurrent-captures">,
235231
HelpText<"Enable flow-sensitive concurrent captures">;

include/swift/SIL/SILDeclRef.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ struct SILDeclRef {
225225
enum class ManglingKind {
226226
Default,
227227
DynamicThunk,
228-
AsyncHandlerBody
229228
};
230229

231230
/// Produce a mangled form of this constant.

lib/AST/ASTMangler.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ std::string ASTMangler::mangleClosureEntity(const AbstractClosureExpr *closure,
8989

9090
std::string ASTMangler::mangleEntity(const ValueDecl *decl, SymbolKind SKind) {
9191
beginMangling();
92-
appendEntity(decl, SKind == SymbolKind::AsyncHandlerBody);
92+
appendEntity(decl);
9393
appendSymbolKind(SKind);
9494
return finalize();
9595
}
@@ -818,7 +818,6 @@ std::string ASTMangler::mangleGenericSignature(const GenericSignature sig) {
818818
void ASTMangler::appendSymbolKind(SymbolKind SKind) {
819819
switch (SKind) {
820820
case SymbolKind::Default: return;
821-
case SymbolKind::AsyncHandlerBody: return;
822821
case SymbolKind::DynamicThunk: return appendOperator("TD");
823822
case SymbolKind::SwiftAsObjCThunk: return appendOperator("To");
824823
case SymbolKind::ObjCAsSwiftThunk: return appendOperator("TO");
@@ -2449,7 +2448,7 @@ void ASTMangler::appendFunctionSignature(AnyFunctionType *fn,
24492448
FunctionManglingKind functionMangling) {
24502449
appendFunctionResultType(fn->getResult(), forDecl);
24512450
appendFunctionInputType(fn->getParams(), forDecl);
2452-
if (fn->isAsync() || functionMangling == AsyncHandlerBodyMangling)
2451+
if (fn->isAsync())
24532452
appendOperator("Ya");
24542453
if (fn->isSendable())
24552454
appendOperator("Yb");
@@ -2998,7 +2997,7 @@ void ASTMangler::appendEntity(const ValueDecl *decl, StringRef EntityOp,
29982997
appendOperator("Z");
29992998
}
30002999

3001-
void ASTMangler::appendEntity(const ValueDecl *decl, bool isAsyncHandlerBody) {
3000+
void ASTMangler::appendEntity(const ValueDecl *decl) {
30023001
assert(!isa<ConstructorDecl>(decl));
30033002
assert(!isa<DestructorDecl>(decl));
30043003

@@ -3019,8 +3018,7 @@ void ASTMangler::appendEntity(const ValueDecl *decl, bool isAsyncHandlerBody) {
30193018

30203019
appendContextOf(decl);
30213020
appendDeclName(decl);
3022-
appendDeclType(decl, isAsyncHandlerBody ? AsyncHandlerBodyMangling
3023-
: FunctionMangling);
3021+
appendDeclType(decl, FunctionMangling);
30243022
appendOperator("F");
30253023
if (decl->isStatic())
30263024
appendOperator("Z");

lib/AST/Decl.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6957,28 +6957,6 @@ bool AbstractFunctionDecl::isSendable() const {
69576957
return getAttrs().hasAttribute<SendableAttr>();
69586958
}
69596959

6960-
bool AbstractFunctionDecl::isAsyncHandler() const {
6961-
auto func = dyn_cast<FuncDecl>(this);
6962-
if (!func)
6963-
return false;
6964-
6965-
auto mutableFunc = const_cast<FuncDecl *>(func);
6966-
return evaluateOrDefault(getASTContext().evaluator,
6967-
IsAsyncHandlerRequest{mutableFunc},
6968-
false);
6969-
}
6970-
6971-
bool AbstractFunctionDecl::canBeAsyncHandler() const {
6972-
auto func = dyn_cast<FuncDecl>(this);
6973-
if (!func)
6974-
return false;
6975-
6976-
auto mutableFunc = const_cast<FuncDecl *>(func);
6977-
return evaluateOrDefault(getASTContext().evaluator,
6978-
CanBeAsyncHandlerRequest{mutableFunc},
6979-
false);
6980-
}
6981-
69826960
BraceStmt *AbstractFunctionDecl::getBody(bool canSynthesize) const {
69836961
if ((getBodyKind() == BodyKind::Synthesize ||
69846962
getBodyKind() == BodyKind::Unparsed) &&

lib/AST/TypeCheckRequests.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -633,20 +633,6 @@ void SelfAccessKindRequest::cacheResult(SelfAccessKind value) const {
633633
funcDecl->setSelfAccessKind(value);
634634
}
635635

636-
//----------------------------------------------------------------------------//
637-
// IsAsyncHandlerRequest computation.
638-
//----------------------------------------------------------------------------//
639-
640-
Optional<bool> IsAsyncHandlerRequest::getCachedResult() const {
641-
auto *funcDecl = std::get<0>(getStorage());
642-
return funcDecl->getCachedIsAsyncHandler();
643-
}
644-
645-
void IsAsyncHandlerRequest::cacheResult(bool value) const {
646-
auto *funcDecl = std::get<0>(getStorage());
647-
funcDecl->setIsAsyncHandler(value);
648-
}
649-
650636
//----------------------------------------------------------------------------//
651637
// IsGetterMutatingRequest computation.
652638
//----------------------------------------------------------------------------//

lib/Frontend/CompilerInvocation.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,6 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
411411
Args.hasFlag(OPT_enable_infer_public_concurrent_value,
412412
OPT_disable_infer_public_concurrent_value,
413413
false);
414-
Opts.EnableExperimentalAsyncHandler |=
415-
Args.hasArg(OPT_enable_experimental_async_handler);
416414
Opts.EnableExperimentalFlowSensitiveConcurrentCaptures |=
417415
Args.hasArg(OPT_enable_experimental_flow_sensitive_concurrent_captures);
418416

lib/SIL/IR/SILDeclRef.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -777,9 +777,6 @@ std::string SILDeclRef::mangle(ManglingKind MKind) const {
777777
case SILDeclRef::ManglingKind::DynamicThunk:
778778
SKind = ASTMangler::SymbolKind::DynamicThunk;
779779
break;
780-
case SILDeclRef::ManglingKind::AsyncHandlerBody:
781-
SKind = ASTMangler::SymbolKind::AsyncHandlerBody;
782-
break;
783780
}
784781

785782
switch (kind) {

lib/SILGen/SILGen.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -421,11 +421,6 @@ SILGenModule::getRunTaskForBridgedAsyncMethod() {
421421
"_runTaskForBridgedAsyncMethod");
422422
}
423423
FuncDecl *
424-
SILGenModule::getRunAsyncHandler() {
425-
return lookupConcurrencyIntrinsic(getASTContext(), RunAsyncHandler,
426-
"_runAsyncHandler");
427-
}
428-
FuncDecl *
429424
SILGenModule::getCheckExpectedExecutor() {
430425
return lookupConcurrencyIntrinsic(getASTContext(), CheckExpectedExecutor,
431426
"_checkExpectedExecutor");

lib/SILGen/SILGen.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor<SILGenModule> {
131131
Optional<FuncDecl*> ResumeUnsafeContinuation;
132132
Optional<FuncDecl*> ResumeUnsafeThrowingContinuation;
133133
Optional<FuncDecl*> ResumeUnsafeThrowingContinuationWithError;
134-
Optional<FuncDecl*> RunAsyncHandler;
135134
Optional<FuncDecl*> CheckExpectedExecutor;
136135

137136
public:
@@ -507,8 +506,6 @@ class LLVM_LIBRARY_VISIBILITY SILGenModule : public ASTVisitor<SILGenModule> {
507506
FuncDecl *getResumeUnsafeThrowingContinuation();
508507
/// Retrieve the _Concurrency._resumeUnsafeThrowingContinuationWithError intrinsic.
509508
FuncDecl *getResumeUnsafeThrowingContinuationWithError();
510-
/// Retrieve the _Concurrency._runAsyncHandler intrinsic.
511-
FuncDecl *getRunAsyncHandler();
512509
/// Retrieve the _Concurrency._runTaskForBridgedAsyncMethod intrinsic.
513510
FuncDecl *getRunTaskForBridgedAsyncMethod();
514511
/// Retrieve the _Concurrency._checkExpectedExecutor intrinsic.

0 commit comments

Comments
 (0)