SILGen: Support mutable consuming parameters.

Emit a box like we would for a local variable, and move the parameter value into the box, as
part of the prolog.
This commit is contained in:
Joe Groff
2023-01-25 12:40:29 -08:00
parent 704a4363d7
commit 2a187f2606
4 changed files with 45 additions and 14 deletions

View File

@@ -6387,9 +6387,9 @@ Type VarDecl::getType() const {
/// is a let member in an initializer.
bool VarDecl::isSettable(const DeclContext *UseDC,
const DeclRefExpr *base) const {
// Only inout parameters are settable.
// Parameters are settable or not depending on their ownership convention.
if (auto *PD = dyn_cast<ParamDecl>(this))
return PD->isInOut();
return !PD->isImmutableInFunctionBody();
// If this is a 'var' decl, then we're settable if we have storage or a
// setter.