Add a DeclContext Parameter to Opened Archetype Construction

This ensures that opened archetypes always inherit any outer generic parameters from the context in which they reside. This matters because class bounds may bind generic parameters from these outer contexts, and without the outer context you can wind up with ill-formed generic environments like

<τ_0_0, where τ_0_0 : C<T>, τ_0_0 : P>

Where T is otherwise unbound because there is no entry for it among the generic parameters of the environment's associated generic signature.
This commit is contained in:
Robert Widmann
2022-03-02 18:08:31 -08:00
parent d166035dd8
commit d6186c9cfb
32 changed files with 228 additions and 127 deletions

View File

@@ -4523,11 +4523,14 @@ public:
void visitOpenedArchetypeType(const OpenedArchetypeType *archetypeTy) {
using namespace decls_block;
auto sig = archetypeTy->getGenericEnvironment()->getGenericSignature();
auto existentialTypeID = S.addTypeRef(archetypeTy->getExistentialType());
auto interfaceTypeID = S.addTypeRef(archetypeTy->getInterfaceType());
auto sigID = S.addGenericSignatureRef(sig);
unsigned abbrCode = S.DeclTypeAbbrCodes[OpenedArchetypeTypeLayout::Code];
OpenedArchetypeTypeLayout::emitRecord(S.Out, S.ScratchRecord, abbrCode,
existentialTypeID, interfaceTypeID);
existentialTypeID, interfaceTypeID,
sigID);
}
void