Implement (de-)serialization for open_existential[_ref].

Swift SVN r13898
This commit is contained in:
Doug Gregor
2014-02-14 05:01:18 +00:00
parent cf5aaa2112
commit 1fa4612eb8
5 changed files with 38 additions and 5 deletions

View File

@@ -1685,8 +1685,14 @@ void Serializer::writeType(Type ty) {
case TypeKind::Archetype: {
auto archetypeTy = cast<ArchetypeType>(ty.getPointer());
assert(!archetypeTy->getOpenedExistentialType() &&
"Opened existential type cannot be serialized");
// 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;
}
TypeID indexOrParentID;
if (archetypeTy->isPrimary())
@@ -2024,6 +2030,7 @@ void Serializer::writeAllDeclsAndTypes() {
registerDeclTypeAbbr<OptionalTypeLayout>();
registerDeclTypeAbbr<UncheckedOptionalTypeLayout>();
registerDeclTypeAbbr<DynamicSelfTypeLayout>();
registerDeclTypeAbbr<OpenedExistentialTypeLayout>();
registerDeclTypeAbbr<TypeAliasLayout>();
registerDeclTypeAbbr<GenericTypeParamTypeLayout>();