Skip to content

Commit efa1b13

Browse files
committed
Add an assertion and a comment
1 parent dc2888f commit efa1b13

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/SILGen/SILGenBridging.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,15 +1618,20 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
16181618
}
16191619
}
16201620

1621-
// If we are bridging a Swift method with Any return value(s), create a
1622-
// stack allocation to hold the result(s), since Any is address-only.
16231621
SmallVector<SILValue, 4> args;
16241622
if (substConv.hasIndirectSILResults()) {
16251623
if (F.getRepresentation() ==
16261624
SILFunctionType::Representation::CFunctionPointer) {
1627-
args.push_back(F.begin()->createFunctionArgument(
1628-
substConv.getSingleSILResultType(getTypeExpansionContext())));
1625+
// Pass the result address of the thunk to the native function.
1626+
auto resultTy =
1627+
F.getConventions().getSingleSILResultType(getTypeExpansionContext());
1628+
assert(resultTy ==
1629+
substConv.getSingleSILResultType(getTypeExpansionContext()) &&
1630+
"result type mismatch");
1631+
args.push_back(F.begin()->createFunctionArgument(resultTy));
16291632
} else {
1633+
// If we are bridging a Swift method with Any return value(s), create a
1634+
// stack allocation to hold the result(s), since Any is address-only.
16301635
for (auto result : substConv.getResults()) {
16311636
if (!substConv.isSILIndirect(result)) {
16321637
continue;

0 commit comments

Comments
 (0)