[Property wrappers] Fix handling of @autoclosure in init(wrappedValue:)

If the 'wrappedValue:' parameter is an escaping autoclosure, and a
struct property is marked with that property wrapper, the memberwise
initializer of the struct is now synthesized with an escaping
autoclosure for that property.
This commit is contained in:
Roopesh Chander
2019-11-17 02:41:35 +00:00
committed by Doug Gregor
parent 7bc4148bda
commit 9c2dca7d6a
10 changed files with 145 additions and 14 deletions

View File

@@ -750,7 +750,8 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, Expr *value,
ctx.getIdentifier("$input_value"),
dc);
param->setSpecifier(ParamSpecifier::Owned);
param->setInterfaceType(function.getDecl()->getInterfaceType());
auto vd = cast<VarDecl>(function.getDecl());
param->setInterfaceType(vd->getPropertyWrapperInitValueInterfaceType());
params = ParameterList::create(ctx, SourceLoc(), {param}, SourceLoc());
}
@@ -800,7 +801,7 @@ void SILGenFunction::emitGeneratorFunction(SILDeclRef function, VarDecl *var) {
// will be in terms of the original property's type.
if (auto originalProperty = var->getOriginalWrappedProperty()) {
if (originalProperty->isPropertyMemberwiseInitializedWithWrappedType()) {
interfaceType = originalProperty->getValueInterfaceType();
interfaceType = originalProperty->getPropertyWrapperInitValueInterfaceType();
}
}