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 @@ -1618,15 +1618,20 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
1618
1618
}
1619
1619
}
1620
1620
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.
1623
1621
SmallVector<SILValue, 4 > args;
1624
1622
if (substConv.hasIndirectSILResults ()) {
1625
1623
if (F.getRepresentation () ==
1626
1624
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));
1629
1632
} 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.
1630
1635
for (auto result : substConv.getResults ()) {
1631
1636
if (!substConv.isSILIndirect (result)) {
1632
1637
continue ;
You can’t perform that action at this time.
0 commit comments