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