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
10 changes: 6 additions & 4 deletions lib/IRGen/GenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6346,10 +6346,12 @@ void irgen::emitAsyncReturn(IRGenFunction &IGF, AsyncContextLayout &asyncLayout,
if (combinedTy->isVoidTy()) {
assert(result.empty() && "Unexpected result values");
} else {
Explosion native = nativeSchema.mapIntoNative(
IGM, IGF, result, funcResultTypeInContext, /*isOutlined*/ false);
if (auto *structTy = dyn_cast<llvm::StructType>(combinedTy)) {
llvm::Value *nativeAgg = llvm::UndefValue::get(structTy);
for (unsigned i = 0, e = result.size(); i < e; ++i) {
llvm::Value *elt = result.claimNext();
for (unsigned i = 0, e = native.size(); i < e; ++i) {
llvm::Value *elt = native.claimNext();
auto *nativeTy = structTy->getElementType(i);
elt = convertForDirectError(IGF, elt, nativeTy,
/*forExtraction*/ false);
Expand All @@ -6360,9 +6362,9 @@ void irgen::emitAsyncReturn(IRGenFunction &IGF, AsyncContextLayout &asyncLayout,
while (!out.empty()) {
nativeResultsStorage.push_back(out.claimNext());
}
} else if (!result.empty()) {
} else if (!native.empty()) {
auto *converted = convertForDirectError(
IGF, result.claimNext(), combinedTy, /*forExtraction*/ false);
IGF, native.claimNext(), combinedTy, /*forExtraction*/ false);
nativeResultsStorage.push_back(converted);
} else {
nativeResultsStorage.push_back(llvm::UndefValue::get(combinedTy));
Expand Down
10 changes: 10 additions & 0 deletions test/IRGen/typed_throws.swift
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,13 @@ func callSmallErrorLargerResult() {
}
}
}

struct SomeStruct {
let x: Int
let y: UInt32
let z: UInt32
}

func someFunc() async throws(SmallError) -> SomeStruct {
SomeStruct(x: 42, y: 23, z: 25)
}