Push ArchetypeType's API down to subclasses.

And clean up code that conditionally works only with certain kinds of archetype along the way.
This commit is contained in:
Joe Groff
2018-12-12 13:26:16 -08:00
parent 4f0f11f6bb
commit 89979137fc
37 changed files with 265 additions and 328 deletions

View File

@@ -3792,19 +3792,10 @@ void Serializer::writeType(Type ty) {
}
case TypeKind::PrimaryArchetype:
case TypeKind::OpenedArchetype:
case TypeKind::NestedArchetype: {
auto archetypeTy = cast<ArchetypeType>(ty.getPointer());
// Opened existential types use a separate layout.
if (auto existentialTy = archetypeTy->getOpenedExistentialType()) {
unsigned abbrCode = DeclTypeAbbrCodes[OpenedExistentialTypeLayout::Code];
OpenedExistentialTypeLayout::emitRecord(Out, ScratchRecord, abbrCode,
addTypeRef(existentialTy));
break;
}
auto env = archetypeTy->getGenericEnvironment();
auto env = archetypeTy->getPrimary()->getGenericEnvironment();
assert(env && "Primary archetype without generic environment?");
GenericEnvironmentID envID = addGenericEnvironmentRef(env);
@@ -3816,6 +3807,14 @@ void Serializer::writeType(Type ty) {
break;
}
case TypeKind::OpenedArchetype: {
auto archetypeTy = cast<OpenedArchetypeType>(ty.getPointer());
unsigned abbrCode = DeclTypeAbbrCodes[OpenedExistentialTypeLayout::Code];
OpenedExistentialTypeLayout::emitRecord(Out, ScratchRecord, abbrCode,
addTypeRef(archetypeTy->getOpenedExistentialType()));
break;
}
case TypeKind::GenericTypeParam: {
auto genericParam = cast<GenericTypeParamType>(ty.getPointer());
unsigned abbrCode = DeclTypeAbbrCodes[GenericTypeParamTypeLayout::Code];