File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -1623,15 +1623,20 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
1623
1623
}
1624
1624
}
1625
1625
1626
- // If we are bridging a Swift method with Any return value(s), create a
1627
- // stack allocation to hold the result(s), since Any is address-only.
1628
1626
SmallVector<SILValue, 4 > args;
1629
1627
if (substConv.hasIndirectSILResults ()) {
1630
1628
if (F.getRepresentation () ==
1631
1629
SILFunctionType::Representation::CFunctionPointer) {
1632
- args.push_back (F.begin ()->createFunctionArgument (
1633
- substConv.getSingleSILResultType (getTypeExpansionContext ())));
1630
+ // Pass the result address of the thunk to the native function.
1631
+ auto resultTy =
1632
+ F.getConventions ().getSingleSILResultType (getTypeExpansionContext ());
1633
+ assert (resultTy ==
1634
+ substConv.getSingleSILResultType (getTypeExpansionContext ()) &&
1635
+ " result type mismatch" );
1636
+ args.push_back (F.begin ()->createFunctionArgument (resultTy));
1634
1637
} else {
1638
+ // If we are bridging a Swift method with Any return value(s), create a
1639
+ // stack allocation to hold the result(s), since Any is address-only.
1635
1640
for (auto result : substConv.getResults ()) {
1636
1641
if (!substConv.isSILIndirect (result)) {
1637
1642
continue ;
You can’t perform that action at this time.
0 commit comments