Skip to content

Commit ee9675d

Browse files
committed
SILGen: Handle indirect result correctly in throwing foreign-to-native thunks.
1 parent a3325bb commit ee9675d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/SILGen/SILGenBridging.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,6 +1011,11 @@ void SILGenFunction::emitNativeToForeignThunk(SILDeclRef thunk) {
10111011
{
10121012
B.emitBlock(normalBB);
10131013
SILValue nativeResult = normalBB->createBBArg(swiftResultTy);
1014+
1015+
if (substTy->hasIndirectResults()) {
1016+
assert(substTy->getNumAllResults() == 1);
1017+
nativeResult = args[0];
1018+
}
10141019

10151020
// In this branch, the eventual return value is mostly created
10161021
// by bridging the native return value, but we may need to

test/SILGen/objc_bridging_any.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ class SwiftIdLover : NSObject, Anyable {
488488
dynamic var maybeAnyProperty: Any?
489489

490490
subscript(_: IndexForAnySubscript) -> Any { get {} set {} }
491+
492+
func methodReturningAnyOrError() throws -> Any {}
491493
}
492494

493495
class IndexForAnySubscript {}

0 commit comments

Comments
 (0)