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