Skip to content

Commit cf2af68

Browse files
authored
Merge pull request swiftlang#76302 from drexin/wip-typed-throws-empty
[IRGen] Fix SignatureExpansion::expandAsyncAwaitType
2 parents 0c30f55 + a4c1d2e commit cf2af68

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

Diff for: lib/IRGen/GenCall.cpp

+7-10
Original file line numberDiff line numberDiff line change
@@ -2330,17 +2330,14 @@ void SignatureExpansion::expandAsyncAwaitType() {
23302330
if (!nativeError.shouldReturnTypedErrorIndirectly()) {
23312331
auto combined = combineResultAndTypedErrorType(IGM, native, nativeError);
23322332

2333-
if (combined.combinedTy->isVoidTy()) {
2334-
addErrorResult();
2335-
return;
2336-
}
2337-
2338-
if (auto *structTy = dyn_cast<llvm::StructType>(combined.combinedTy)) {
2339-
for (auto *elem : structTy->elements()) {
2340-
components.push_back(elem);
2333+
if (!combined.combinedTy->isVoidTy()) {
2334+
if (auto *structTy = dyn_cast<llvm::StructType>(combined.combinedTy)) {
2335+
for (auto *elem : structTy->elements()) {
2336+
components.push_back(elem);
2337+
}
2338+
} else {
2339+
components.push_back(combined.combinedTy);
23412340
}
2342-
} else {
2343-
components.push_back(combined.combinedTy);
23442341
}
23452342
addErrorResult();
23462343
ResultIRType = llvm::StructType::get(IGM.getLLVMContext(), components);

Diff for: test/IRGen/typed_throws.swift

+15
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
// RUN: %target-swift-frontend -primary-file %s -emit-ir -enable-library-evolution
88

9+
// RUN: %target-swift-frontend -primary-file %s -emit-ir -O
10+
911
// XFAIL: CPU=arm64e
1012
// REQUIRES: PTRSIZE=64
1113

@@ -232,3 +234,16 @@ protocol Proto {
232234
// This used to crash.
233235
static func f2() throws(SP) -> Int64
234236
}
237+
238+
@inline(never)
239+
@available(SwiftStdlib 6.0, *)
240+
public func passthroughAsync<T, E: Error>(f: () async throws(E) -> T) async throws(E) -> T {
241+
try await f()
242+
}
243+
244+
@available(SwiftStdlib 6.0, *)
245+
public func reabstractAsyncVoidThrowsNever() async {
246+
await passthroughAsync {
247+
()
248+
}
249+
}

0 commit comments

Comments
 (0)