Give opened archetypes a generic environment.

And maybe allow nested types to live on them.
This commit is contained in:
Joe Groff
2019-01-07 16:03:27 -08:00
parent 345e9881d1
commit 0cfca9496a
16 changed files with 105 additions and 41 deletions

View File

@@ -1036,7 +1036,9 @@ shouldBePartiallySpecialized(Type Replacement,
llvm::SmallSetVector<ArchetypeType *, 2> UsedArchetypes;
Replacement.visit([&](Type Ty) {
if (auto Archetype = Ty->getAs<ArchetypeType>()) {
UsedArchetypes.insert(Archetype->getPrimary());
if (auto Primary = dyn_cast<PrimaryArchetypeType>(Archetype->getRoot())) {
UsedArchetypes.insert(Primary);
}
}
});
@@ -1264,7 +1266,9 @@ void FunctionSignaturePartialSpecializer::collectUsedCallerArchetypes(
// Add used generic parameters/archetypes.
Replacement.visit([&](Type Ty) {
if (auto Archetype = Ty->getAs<ArchetypeType>()) {
UsedCallerArchetypes.insert(Archetype->getPrimary());
if (auto Primary = dyn_cast<PrimaryArchetypeType>(Archetype->getRoot())) {
UsedCallerArchetypes.insert(Primary);
}
}
});
}