[SILGen] InitAccessors: Generalize AccessorComponent::emitValue

Instead of taking a setter type, let's switch over to a more general
`AccessorKind` which allows us to cover init accessors and simplify
`emitApplySetterToBase`.
This commit is contained in:
Pavel Yaskevich
2023-07-12 10:18:59 -07:00
parent 75ac13807e
commit 5fd502b150
3 changed files with 35 additions and 27 deletions

View File

@@ -1755,7 +1755,7 @@ ParamDecl *SILGenFunction::isMappedToInitAccessorArgument(VarDecl *property) {
return arg->second;
}
std::pair<SILValue, CanSILFunctionType>
SILValue
SILGenFunction::emitApplyOfSetterToBase(SILLocation loc, SILDeclRef setter,
ManagedValue base,
SubstitutionMap substitutions) {
@@ -1783,8 +1783,7 @@ SILGenFunction::emitApplyOfSetterToBase(SILLocation loc, SILDeclRef setter,
getTypeExpansionContext());
};
auto setterTy = getSetterType(setterFRef);
SILFunctionConventions setterConv(setterTy, SGM.M);
SILFunctionConventions setterConv(getSetterType(setterFRef), SGM.M);
// Emit captures for the setter
SmallVector<SILValue, 4> capturedArgs;
@@ -1822,5 +1821,5 @@ SILGenFunction::emitApplyOfSetterToBase(SILLocation loc, SILDeclRef setter,
PartialApplyInst *setterPAI =
B.createPartialApply(loc, setterFRef, substitutions, capturedArgs,
ParameterConvention::Direct_Guaranteed);
return {emitManagedRValueWithCleanup(setterPAI).getValue(), setterTy};
return emitManagedRValueWithCleanup(setterPAI).getValue();
}