[DI] TypeWrappers: Support conformance requirements on Wrapper/Storage parameters

This commit is contained in:
Pavel Yaskevich
2022-12-19 14:17:38 -08:00
parent 4a0f9cac72
commit 01b5a9d182
3 changed files with 64 additions and 9 deletions

View File

@@ -1315,15 +1315,24 @@ void LifetimeChecker::injectTypeWrapperStorageInitalization() {
wrapperInitArgs.push_back(storageObj);
wrapperInitArgs.push_back(typeWrapperType);
// <wrapper-var> = <TypeWrapper>.init(storage: tmpStorage)
auto wrapperInitResult = b.createApply(
loc, typeWrapperInitRef,
SubstitutionMap::get(typeWrapperInit->getGenericSignature(),
/*substitutions=*/
{wrappedType->getMetatypeInstanceType(),
storageType.getASTType()},
/*conformances=*/{}),
wrapperInitArgs);
TypeSubstitutionMap wrapperInitSubs;
{
auto sig =
typeWrapperInit->getGenericSignature().getCanonicalSignature();
wrapperInitSubs[sig.getGenericParams()[0]] =
wrappedType->getMetatypeInstanceType();
wrapperInitSubs[sig.getGenericParams()[1]] = storageType.getASTType();
}
// <wrapper-var> = <TypeWrapper>.init(for: <Type>, storage: tmpStorage)
auto wrapperInitResult =
b.createApply(loc, typeWrapperInitRef,
SubstitutionMap::get(
typeWrapperInit->getGenericSignature(),
QueryTypeSubstitutionMap{wrapperInitSubs},
LookUpConformanceInModule(
ctor->getDeclContext()->getParentModule())),
wrapperInitArgs);
// self.$storage is a property access so it has to has to be wrapped
// in begin/end access instructions.