[Property Wrappers] Use autoclosure information from CSApply to compute

`VarDecl::getPropertyWrapperInitValueInterfaceType`.
This commit is contained in:
Holly Borla
2020-07-13 16:23:31 -07:00
parent bf47403162
commit a6c33a9611
18 changed files with 137 additions and 159 deletions

View File

@@ -6067,21 +6067,14 @@ bool VarDecl::isPropertyMemberwiseInitializedWithWrappedType() const {
return allAttachedPropertyWrappersHaveWrappedValueInit();
}
bool VarDecl::isInnermostPropertyWrapperInitUsesEscapingAutoClosure() const {
auto customAttrs = getAttachedPropertyWrappers();
if (customAttrs.empty())
return false;
unsigned innermostWrapperIndex = customAttrs.size() - 1;
auto typeInfo = getAttachedPropertyWrapperTypeInfo(innermostWrapperIndex);
return typeInfo.isWrappedValueInitUsingEscapingAutoClosure;
}
Type VarDecl::getPropertyWrapperInitValueInterfaceType() const {
Type valueInterfaceTy = getValueInterfaceType();
auto wrapperInfo = getPropertyWrapperBackingPropertyInfo();
if (!wrapperInfo || !wrapperInfo.wrappedValuePlaceholder)
return Type();
if (isInnermostPropertyWrapperInitUsesEscapingAutoClosure())
return FunctionType::get({}, valueInterfaceTy);
Type valueInterfaceTy = wrapperInfo.wrappedValuePlaceholder->getType();
if (valueInterfaceTy->hasArchetype())
valueInterfaceTy = valueInterfaceTy->mapTypeOutOfContext();
return valueInterfaceTy;
}