[Sema] TypeWrappers: Subsume property init before injecting it into $Storage

It was done in `maybeAddTypeWrapperDefaultArg` before because
user-defined initializers weren't supported but now property
initializers need to be subsumed earlier to make sure that
SILGen doesn't try to emit them into user-defined initializers.
This commit is contained in:
Pavel Yaskevich
2022-10-05 11:52:06 -07:00
committed by Pavel Yaskevich
parent 73e9f27968
commit 24b2bcae09
2 changed files with 7 additions and 14 deletions

View File

@@ -213,20 +213,6 @@ static void maybeAddTypeWrapperDefaultArg(ParamDecl *arg, VarDecl *var,
if (!initExpr)
return;
// Type wrapper variables are never initialized directly,
// initialization expression (if any) becomes an default
// argument of the initializer synthesized by the type wrapper.
{
// Since type wrapper is applied to backing property, that's
// the the initializer it subsumes.
if (var->hasAttachedPropertyWrapper()) {
auto *backingVar = var->getPropertyWrapperBackingProperty();
PBD = backingVar->getParentPatternBinding();
}
PBD->setInitializerSubsumed(/*index=*/0);
}
arg->setDefaultExpr(initExpr, PBD->isInitializerChecked(/*index=*/0));
arg->setDefaultArgumentKind(DefaultArgumentKind::Normal);
}