Skip to content

Commit ebca3f8

Browse files
committed
[Sema]Set isAsync only when it is in async context
1 parent 7365d09 commit ebca3f8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/Sema/TypeOfReference.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2214,7 +2214,7 @@ isInvalidPartialApplication(ConstraintSystem &cs,
22142214
/// the full opened type and the reference's type.
22152215
static DeclReferenceType getTypeOfReferenceWithSpecialTypeCheckingSemantics(
22162216
ConstraintSystem &CS, ConstraintLocator *locator,
2217-
DeclTypeCheckingSemantics semantics) {
2217+
DeclTypeCheckingSemantics semantics, DeclContext *useDC) {
22182218
switch (semantics) {
22192219
case DeclTypeCheckingSemantics::Normal:
22202220
llvm_unreachable("Decl does not have special type checking semantics!");
@@ -2261,10 +2261,11 @@ static DeclReferenceType getTypeOfReferenceWithSpecialTypeCheckingSemantics(
22612261
CS.getConstraintLocator(locator, ConstraintLocator::ThrownErrorType),
22622262
0);
22632263
FunctionType::Param arg(escapeClosure);
2264+
bool isAsync = CS.isAsynchronousContext(useDC);
22642265
auto bodyClosure = FunctionType::get(arg, result,
22652266
FunctionType::ExtInfoBuilder()
22662267
.withNoEscape(true)
2267-
.withAsync(true)
2268+
.withAsync(isAsync)
22682269
.withThrows(true, thrownError)
22692270
.build());
22702271
FunctionType::Param args[] = {
@@ -2275,7 +2276,7 @@ static DeclReferenceType getTypeOfReferenceWithSpecialTypeCheckingSemantics(
22752276
auto refType = FunctionType::get(args, result,
22762277
FunctionType::ExtInfoBuilder()
22772278
.withNoEscape(false)
2278-
.withAsync(true)
2279+
.withAsync(isAsync)
22792280
.withThrows(true, thrownError)
22802281
.build());
22812282
return {refType, refType, refType, refType, Type()};
@@ -2370,7 +2371,7 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
23702371
DeclReferenceType declRefType;
23712372
if (semantics != DeclTypeCheckingSemantics::Normal) {
23722373
declRefType = getTypeOfReferenceWithSpecialTypeCheckingSemantics(
2373-
*this, locator, semantics);
2374+
*this, locator, semantics, useDC);
23742375
} else if (auto baseTy = choice.getBaseType()) {
23752376
// Retrieve the type of a reference to the specific declaration choice.
23762377
assert(!baseTy->hasTypeParameter());

0 commit comments

Comments
 (0)