File tree Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Expand file tree Collapse file tree 2 files changed +22
-7
lines changed Original file line number Diff line number Diff line change @@ -2724,13 +2724,11 @@ bool ConstraintSystem::isAsynchronousContext(DeclContext *dc) {
2724
2724
if (auto func = dyn_cast<AbstractFunctionDecl>(dc))
2725
2725
return func->isAsyncContext ();
2726
2726
2727
- if (auto abstractClosure = dyn_cast<AbstractClosureExpr>(dc)) {
2728
- if (Type type = GetClosureType{*this }(abstractClosure)) {
2729
- if (auto fnType = type->getAs <AnyFunctionType>())
2730
- return fnType->isAsync ();
2731
- }
2732
-
2733
- return abstractClosure->isBodyAsync ();
2727
+ if (auto closure = dyn_cast<ClosureExpr>(dc)) {
2728
+ return evaluateOrDefault (
2729
+ getASTContext ().evaluator ,
2730
+ ClosureEffectsRequest{const_cast <ClosureExpr *>(closure)},
2731
+ FunctionType::ExtInfo ()).isAsync ();
2734
2732
}
2735
2733
2736
2734
return false ;
Original file line number Diff line number Diff line change @@ -163,3 +163,20 @@ func testAsyncWithConversions() async {
163
163
// expected-error@-1:7{{expression is 'async' but is not marked with 'await'}}{{7-7=await }}
164
164
// expected-note@-2:7{{call is 'async'}}
165
165
}
166
+
167
+ // rdar://88692889 - make sure overload resolution cues off the presence of
168
+ // 'await' in the body to determine whether to prefer async functions, not
169
+ // whether the closure is in a context where it will be converted to async.
170
+ @available ( SwiftStdlib 5 . 1 , * )
171
+ struct OverloadInImplicitAsyncClosure {
172
+ init ( int: Int ) async throws {
173
+ let task = Task { ( ) -> Self in
174
+ let result = try Self ( int: int)
175
+ return result
176
+ }
177
+
178
+ self = try await task. value
179
+ }
180
+
181
+ init ( int: Int ) throws { }
182
+ }
You can’t perform that action at this time.
0 commit comments