Skip to content

Commit 0aebbea

Browse files
committed
[IRGen] Fix SignatureExpansion::expandAsyncReturnType()
rdar://141962253 This fixes an issue that caused parameters to be dropped when a typed error in an async closure was too big to be returned directly.
1 parent 9d43e7c commit 0aebbea

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/IRGen/GenCall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,9 +2142,9 @@ void SignatureExpansion::expandAsyncReturnType() {
21422142
} else {
21432143
ParamIRTypes.push_back(combined.combinedTy);
21442144
}
2145+
addErrorResult();
2146+
return;
21452147
}
2146-
addErrorResult();
2147-
return;
21482148
}
21492149

21502150
if (native.requiresIndirect() || native.empty()) {

test/IRGen/typed_throws.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,13 @@ func callClosureAsync<T>(t: T) async {
285285
return t
286286
}
287287
}
288+
289+
enum LargeError: Error {
290+
case x
291+
case y(Int64, Int64, Int64, Int64, Int64)
292+
}
293+
294+
// Used to crash the compiler because
295+
func callClosureAsyncIndirectError(f: () async throws(LargeError) -> Int) async throws(LargeError) -> Int {
296+
return try await f()
297+
}

0 commit comments

Comments
 (0)