Skip to content

Commit ad2d86c

Browse files
authored
Merge pull request swiftlang#40620 from xedin/async-open-existential
[TypeChecker] Support `_openExistential` with async functions
2 parents 4b2178c + 34575e3 commit ad2d86c

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,7 @@ static std::pair<Type, Type> getTypeOfReferenceWithSpecialTypeCheckingSemantics(
22782278
FunctionType::ExtInfoBuilder()
22792279
.withNoEscape(true)
22802280
.withThrows(true)
2281+
.withAsync(true)
22812282
.build());
22822283
FunctionType::Param args[] = {
22832284
FunctionType::Param(existentialTy),
@@ -2287,6 +2288,7 @@ static std::pair<Type, Type> getTypeOfReferenceWithSpecialTypeCheckingSemantics(
22872288
FunctionType::ExtInfoBuilder()
22882289
.withNoEscape(false)
22892290
.withThrows(true)
2291+
.withAsync(true)
22902292
.build());
22912293
return {refType, refType};
22922294
}

test/decl/func/async.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,17 @@ func thereIsNoEscape(_ body: () async -> Void) async {
4848
await takeEscaping(escapingBody)
4949
}
5050
}
51+
52+
func testAsyncExistentialOpen(_ v: P1) async {
53+
func syncUnderlyingType<T>(u: T) {}
54+
func syncThrowsUnderlyingType<T>(u: T) throws {}
55+
56+
func asyncUnderlyingType<T>(u: T) async {}
57+
func asyncThrowsUnderlyingType<T>(u: T) async throws {}
58+
59+
_openExistential(v, do: syncUnderlyingType)
60+
await _openExistential(v, do: asyncUnderlyingType)
61+
62+
try! _openExistential(v, do: syncThrowsUnderlyingType)
63+
try! await _openExistential(v, do: asyncThrowsUnderlyingType)
64+
}

0 commit comments

Comments
 (0)