@@ -3788,6 +3788,10 @@ CallEmission::applyPartiallyAppliedSuperMethod(SGFContext C) {
3788
3788
auto subs = callee.getSubstitutions ();
3789
3789
auto upcastedSelf = uncurriedArgs.back ();
3790
3790
3791
+ // Make sure that upcasted self is at +1 since we are going to place it into a
3792
+ // partial_apply.
3793
+ upcastedSelf = upcastedSelf.ensurePlusOne (SGF, loc);
3794
+
3791
3795
auto constantInfo = SGF.getConstantInfo (callee.getMethodName ());
3792
3796
auto functionTy = constantInfo.getSILType ();
3793
3797
ManagedValue superMethod;
@@ -3813,11 +3817,9 @@ CallEmission::applyPartiallyAppliedSuperMethod(SGFContext C) {
3813
3817
if (constantInfo.SILFnType ->isPolymorphic () && !subs.empty ())
3814
3818
partialApplyTy = partialApplyTy.substGenericArgs (module , subs);
3815
3819
3816
- SILValue partialApply =
3817
- SGF.B .createPartialApply (loc, superMethod.getValue (), partialApplyTy,
3818
- subs, {upcastedSelf.forward (SGF)}, closureTy);
3820
+ ManagedValue pa = SGF.B .createPartialApply (loc, superMethod, partialApplyTy,
3821
+ subs, {upcastedSelf}, closureTy);
3819
3822
assert (!closureTy.castTo <SILFunctionType>()->isNoEscape ());
3820
- ManagedValue pa = SGF.emitManagedRValueWithCleanup (partialApply);
3821
3823
firstLevelResult.value = RValue (SGF, loc, formalApplyType.getResult (), pa);
3822
3824
return firstLevelResult;
3823
3825
}
0 commit comments