Carry through the ordinal for opaque type declarations.

Generalize the implementation of opaque type declarations to maintain
the "ordinal", which represents a particular "some" utterance in a
structural opaque type, throughout more of the compiler.

The ordinal value for a given "some" matches with the index of the
corresponding generic parameter in the opaque type declaration's
generic signature. To properly be able to determine the ordinal for a
given "some" type representation, retain all of the "some" type
representations in the `OpaqueTypeDecl` (using trailing storage), so
we can map them to the proper generic parameter and ordinal later on.
This commit is contained in:
Doug Gregor
2021-12-24 22:06:48 -08:00
parent 3892268cc6
commit 99a9c021e2
8 changed files with 101 additions and 41 deletions

View File

@@ -4275,9 +4275,7 @@ DependentMemberType *DependentMemberType::get(Type base,
OpaqueTypeArchetypeType *
OpaqueTypeArchetypeType::get(OpaqueTypeDecl *Decl, unsigned ordinal,
SubstitutionMap Substitutions) {
// TODO [OPAQUE SUPPORT]: multiple opaque types
assert(ordinal == 0 && "we only support one 'some' type per composite type");
auto opaqueParamType = Decl->getUnderlyingInterfaceType();
auto opaqueParamType = Decl->getOpaqueGenericParams()[ordinal];
// TODO: We could attempt to preserve type sugar in the substitution map.
// Currently archetypes are assumed to be always canonical in many places,