@@ -5351,9 +5351,8 @@ CanOpenedArchetypeType OpenedArchetypeType::get(CanType existential,
5351
5351
if (!knownID)
5352
5352
knownID = UUID::fromTime ();
5353
5353
5354
- auto *genericEnv =
5355
- GenericEnvironment::forOpenedExistential (
5356
- existential, SubstitutionMap (), *knownID);
5354
+ auto *genericEnv = GenericEnvironment::forOpenedExistential (
5355
+ existential, *knownID);
5357
5356
5358
5357
// Map the interface type into that environment.
5359
5358
auto result = genericEnv->mapTypeIntoContext (interfaceType)
@@ -5544,10 +5543,19 @@ GenericEnvironment *GenericEnvironment::forOpaqueType(
5544
5543
return env;
5545
5544
}
5546
5545
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
+
5547
5554
// / Create a new generic environment for an opened archetype.
5548
5555
GenericEnvironment *
5549
5556
GenericEnvironment::forOpenedExistential (
5550
- Type existential, SubstitutionMap subs, UUID uuid) {
5557
+ GenericSignature signature, Type existential,
5558
+ SubstitutionMap subs, UUID uuid) {
5551
5559
assert (existential->isExistentialType ());
5552
5560
5553
5561
// TODO: We could attempt to preserve type sugar in the substitution map.
@@ -5569,15 +5577,13 @@ GenericEnvironment::forOpenedExistential(
5569
5577
if (found != environments.end ()) {
5570
5578
auto *existingEnv = found->second ;
5571
5579
assert (existingEnv->getOpenedExistentialType ()->isEqual (existential));
5580
+ assert (existingEnv->getGenericSignature ().getPointer () == signature.getPointer ());
5572
5581
assert (existingEnv->getOuterSubstitutions () == subs);
5573
5582
assert (existingEnv->getOpenedExistentialUUID () == uuid);
5574
5583
5575
5584
return existingEnv;
5576
5585
}
5577
5586
5578
- auto parentSig = subs.getGenericSignature ().getCanonicalSignature ();
5579
- auto signature = ctx.getOpenedExistentialSignature (existential, parentSig);
5580
-
5581
5587
// Allocate and construct the new environment.
5582
5588
unsigned numGenericParams = signature.getGenericParams ().size ();
5583
5589
size_t bytes = totalSizeToAlloc<SubstitutionMap,
0 commit comments