Skip to content

Commit 2e433d4

Browse files
committed
Fix unowned callee context
1 parent c440040 commit 2e433d4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/SILGen/SILGenApply.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,9 +1687,12 @@ static SILValue emitRawApply(SILGenFunction &SGF,
16871687
ArrayRef<SILValue> indirectResultAddrs) {
16881688
SILFunctionConventions substFnConv(substFnType, SGF.SGM.M);
16891689
// Get the callee value.
1690-
SILValue fnValue = substFnType->isCalleeConsumed()
1691-
? fn.forward(SGF)
1692-
: fn.borrow(SGF, loc).getValue();
1690+
bool isConsumed = substFnType->isCalleeConsumed();
1691+
bool isUnowned =
1692+
substFnType->getCalleeConvention() == ParameterConvention::Direct_Unowned;
1693+
SILValue fnValue =
1694+
isUnowned ? fn.getValue()
1695+
: isConsumed ? fn.forward(SGF) : fn.borrow(SGF, loc).getValue();
16931696

16941697
SmallVector<SILValue, 4> argValues;
16951698

0 commit comments

Comments
 (0)