File tree Expand file tree Collapse file tree 2 files changed +15
-21
lines changed Expand file tree Collapse file tree 2 files changed +15
-21
lines changed Original file line number Diff line number Diff line change @@ -1744,7 +1744,21 @@ namespace {
1744
1744
}
1745
1745
1746
1746
bool isInAsynchronousContext () const {
1747
- return isAsynchronousContext (getDeclContext ());
1747
+ auto *dc = getDeclContext ();
1748
+
1749
+ if (auto func = dyn_cast<AbstractFunctionDecl>(dc)) {
1750
+ return func->isAsyncContext ();
1751
+ }
1752
+
1753
+ if (auto closure = dyn_cast<AbstractClosureExpr>(dc)) {
1754
+ if (auto type = closure->getType ()) {
1755
+ if (auto fnType = type->getAs <AnyFunctionType>()) {
1756
+ return fnType->isAsync ();
1757
+ }
1758
+ }
1759
+ }
1760
+
1761
+ return false ;
1748
1762
}
1749
1763
1750
1764
enum class AsyncMarkingResult {
@@ -4193,22 +4207,6 @@ bool swift::completionContextUsesConcurrencyFeatures(const DeclContext *dc) {
4193
4207
return contextUsesConcurrencyFeatures (dc);
4194
4208
}
4195
4209
4196
- bool swift::isAsynchronousContext (const DeclContext *dc) {
4197
- if (auto func = dyn_cast<AbstractFunctionDecl>(dc)) {
4198
- return func->isAsyncContext ();
4199
- }
4200
-
4201
- if (auto closure = dyn_cast<AbstractClosureExpr>(dc)) {
4202
- if (auto type = closure->getType ()) {
4203
- if (auto fnType = type->getAs <AnyFunctionType>()) {
4204
- return fnType->isAsync ();
4205
- }
4206
- }
4207
- }
4208
-
4209
- return false ;
4210
- }
4211
-
4212
4210
AbstractFunctionDecl const *swift::isActorInitOrDeInitContext (
4213
4211
const DeclContext *dc,
4214
4212
llvm::function_ref<bool (const AbstractClosureExpr *)> isSendable) {
Original file line number Diff line number Diff line change @@ -329,10 +329,6 @@ bool isDispatchQueueOperationName(StringRef name);
329
329
bool checkSendableConformance (
330
330
ProtocolConformance *conformance, SendableCheck check);
331
331
332
- // / Check whether the given declaration context is asynchronous e.g.
333
- // / function or a closure declaration marked as `async`.
334
- bool isAsynchronousContext (const DeclContext *dc);
335
-
336
332
// / Check whether we are in an actor's initializer or deinitializer.
337
333
// / \returns nullptr iff we are not in such a declaration. Otherwise,
338
334
// / returns a pointer to the declaration.
You can’t perform that action at this time.
0 commit comments