Skip to content

Commit 99a9d61

Browse files
authored
Merge pull request swiftlang#78273 from drexin/wip-141575655-6.1
[6.1][IRGen] Indirectly pass typed errors for closures with indirect results
2 parents 38fe923 + 50422e7 commit 99a9d61

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/IRGen/GenFunc.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,7 @@ class SyncPartialApplicationForwarderEmission
11881188

11891189
if (resultSchema.requiresIndirect() ||
11901190
errorSchema.shouldReturnTypedErrorIndirectly() ||
1191+
outConv.hasIndirectSILResults() ||
11911192
outConv.hasIndirectSILErrorResults()) {
11921193
auto *typedErrorResultPtr = origParams.claimNext();
11931194
args.add(typedErrorResultPtr);
@@ -1378,6 +1379,7 @@ class AsyncPartialApplicationForwarderEmission
13781379

13791380
if (resultSchema.requiresIndirect() ||
13801381
errorSchema.shouldReturnTypedErrorIndirectly() ||
1382+
outConv.hasIndirectSILResults() ||
13811383
outConv.hasIndirectSILErrorResults()) {
13821384
auto *typedErrorResultPtr = origParams.claimNext();
13831385
args.add(typedErrorResultPtr);

test/IRGen/typed_throws.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,23 @@ func conditionallyCallsThrowError(b: Bool) throws(SmallError) -> Int {
265265
return 0
266266
}
267267
}
268+
269+
func passthroughFixedErrorCall<T>(_ body: () throws(TinyError) -> T) throws(TinyError) -> T {
270+
try body()
271+
}
272+
273+
func passthroughFixedErrorAsync<T>(_ body: () async throws(TinyError) -> T) async throws(TinyError) -> T {
274+
try await body()
275+
}
276+
277+
func callClosureSync<T>(t: T) {
278+
_ = try! passthroughFixedErrorCall { () throws(TinyError) -> T in
279+
return t
280+
}
281+
}
282+
283+
func callClosureAsync<T>(t: T) async {
284+
_ = try! await passthroughFixedErrorAsync { () async throws(TinyError) -> T in
285+
return t
286+
}
287+
}

0 commit comments

Comments
 (0)