Serialization: Fix deserialization of generic typealiases

The recovery logic was erronously kicking in, because it was comparing
the substituted underlying type with the declaration's underlying type.

For a generic typealias, these never equal, so instead, serialize the
unsubstituted type, and substitute it in deserialization.
This commit is contained in:
Slava Pestov
2018-09-11 14:30:30 -07:00
parent e180bf9d4e
commit 3feaf8731a
6 changed files with 74 additions and 39 deletions

View File

@@ -3625,13 +3625,14 @@ void Serializer::writeType(Type ty) {
case TypeKind::NameAlias: {
auto alias = cast<NameAliasType>(ty.getPointer());
const TypeAliasDecl *typeAlias = alias->getDecl();
auto underlyingType = typeAlias->getUnderlyingTypeLoc().getType();
unsigned abbrCode = DeclTypeAbbrCodes[NameAliasTypeLayout::Code];
NameAliasTypeLayout::emitRecord(
Out, ScratchRecord, abbrCode,
addDeclRef(typeAlias, /*allowTypeAliasXRef*/true),
addTypeRef(alias->getParent()),
addTypeRef(alias->getSinglyDesugaredType()),
addTypeRef(underlyingType),
addSubstitutionMapRef(alias->getSubstitutionMap()));
break;
}