@@ -5350,9 +5350,8 @@ CanOpenedArchetypeType OpenedArchetypeType::get(CanType existential,
53505350 if (!knownID)
53515351 knownID = UUID::fromTime ();
53525352
5353- auto *genericEnv =
5354- GenericEnvironment::forOpenedExistential (
5355- existential, SubstitutionMap (), *knownID);
5353+ auto *genericEnv = GenericEnvironment::forOpenedExistential (
5354+ existential, *knownID);
53565355
53575356 // Map the interface type into that environment.
53585357 auto result = genericEnv->mapTypeIntoContext (interfaceType)
@@ -5543,10 +5542,19 @@ GenericEnvironment *GenericEnvironment::forOpaqueType(
55435542 return env;
55445543}
55455544
5545+ // / Create a new generic environment for an opened archetype.
5546+ GenericEnvironment *
5547+ GenericEnvironment::forOpenedExistential (Type existential, UUID uuid) {
5548+ auto &ctx = existential->getASTContext ();
5549+ auto signature = ctx.getOpenedExistentialSignature (existential, GenericSignature ());
5550+ return forOpenedExistential (signature, existential, SubstitutionMap (), uuid);
5551+ }
5552+
55465553// / Create a new generic environment for an opened archetype.
55475554GenericEnvironment *
55485555GenericEnvironment::forOpenedExistential (
5549- Type existential, SubstitutionMap subs, UUID uuid) {
5556+ GenericSignature signature, Type existential,
5557+ SubstitutionMap subs, UUID uuid) {
55505558 assert (existential->isExistentialType ());
55515559
55525560 // TODO: We could attempt to preserve type sugar in the substitution map.
@@ -5568,15 +5576,13 @@ GenericEnvironment::forOpenedExistential(
55685576 if (found != environments.end ()) {
55695577 auto *existingEnv = found->second ;
55705578 assert (existingEnv->getOpenedExistentialType ()->isEqual (existential));
5579+ assert (existingEnv->getGenericSignature ().getPointer () == signature.getPointer ());
55715580 assert (existingEnv->getOuterSubstitutions () == subs);
55725581 assert (existingEnv->getOpenedExistentialUUID () == uuid);
55735582
55745583 return existingEnv;
55755584 }
55765585
5577- auto parentSig = subs.getGenericSignature ().getCanonicalSignature ();
5578- auto signature = ctx.getOpenedExistentialSignature (existential, parentSig);
5579-
55805586 // Allocate and construct the new environment.
55815587 unsigned numGenericParams = signature.getGenericParams ().size ();
55825588 size_t bytes = totalSizeToAlloc<SubstitutionMap,
0 commit comments