Skip to content

Commit 07d362d

Browse files
authored
Merge pull request swiftlang#35664 from DougGregor/async-without-actually-escaping
2 parents f368364 + b7a86bb commit 07d362d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,7 @@ static std::pair<Type, Type> getTypeOfReferenceWithSpecialTypeCheckingSemantics(
19001900
auto bodyClosure = FunctionType::get(arg, result,
19011901
FunctionType::ExtInfoBuilder()
19021902
.withNoEscape(true)
1903+
.withAsync(true)
19031904
.withThrows(true)
19041905
.build());
19051906
FunctionType::Param args[] = {
@@ -1910,6 +1911,7 @@ static std::pair<Type, Type> getTypeOfReferenceWithSpecialTypeCheckingSemantics(
19101911
auto refType = FunctionType::get(args, result,
19111912
FunctionType::ExtInfoBuilder()
19121913
.withNoEscape(false)
1914+
.withAsync(true)
19131915
.withThrows(true)
19141916
.build());
19151917
return {refType, refType};

test/decl/func/async.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,12 @@ protocol P2 {
3939
struct ConformsToP2: P2 {
4040
func f() { } // okay
4141
}
42+
43+
// withoutActuallyEscaping on async functions
44+
func takeEscaping(_: @escaping () async -> Void) async { }
45+
46+
func thereIsNoEscape(_ body: () async -> Void) async {
47+
await withoutActuallyEscaping(body) { escapingBody in
48+
await takeEscaping(escapingBody)
49+
}
50+
}

0 commit comments

Comments
 (0)