Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions lib/IRGen/GenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2330,17 +2330,14 @@ void SignatureExpansion::expandAsyncAwaitType() {
if (!nativeError.shouldReturnTypedErrorIndirectly()) {
auto combined = combineResultAndTypedErrorType(IGM, native, nativeError);

if (combined.combinedTy->isVoidTy()) {
addErrorResult();
return;
}

if (auto *structTy = dyn_cast<llvm::StructType>(combined.combinedTy)) {
for (auto *elem : structTy->elements()) {
components.push_back(elem);
if (!combined.combinedTy->isVoidTy()) {
if (auto *structTy = dyn_cast<llvm::StructType>(combined.combinedTy)) {
for (auto *elem : structTy->elements()) {
components.push_back(elem);
}
} else {
components.push_back(combined.combinedTy);
}
} else {
components.push_back(combined.combinedTy);
}
addErrorResult();
ResultIRType = llvm::StructType::get(IGM.getLLVMContext(), components);
Expand Down
15 changes: 15 additions & 0 deletions test/IRGen/typed_throws.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

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

// RUN: %target-swift-frontend -primary-file %s -emit-ir -O

// XFAIL: CPU=arm64e
// REQUIRES: PTRSIZE=64

Expand Down Expand Up @@ -232,3 +234,16 @@ protocol Proto {
// This used to crash.
static func f2() throws(SP) -> Int64
}

@inline(never)
@available(SwiftStdlib 6.0, *)
public func passthroughAsync<T, E: Error>(f: () async throws(E) -> T) async throws(E) -> T {
try await f()
}

@available(SwiftStdlib 6.0, *)
public func reabstractAsyncVoidThrowsNever() async {
await passthroughAsync {
()
}
}