AST/Serialization: Some assertions for extensions

These helped me rule out my first theory about another bug, even
though it turned out to be unrelated.
This commit is contained in:
Slava Pestov
2017-05-22 14:18:23 -07:00
parent 16be7ce496
commit 5197f38cda
3 changed files with 7 additions and 2 deletions

View File

@@ -1675,6 +1675,7 @@ void Serializer::writeCrossReference(const DeclContext *DC, uint32_t pathLen) {
case DeclContextKind::ExtensionDecl: {
auto ext = cast<ExtensionDecl>(DC);
Type baseTy = ext->getExtendedType();
assert(!baseTy->hasUnboundGenericType());
writeCrossReference(baseTy->getAnyNominal(), pathLen + 1);
abbrCode = DeclTypeAbbrCodes[XRefExtensionPathPieceLayout::Code];
@@ -2424,6 +2425,7 @@ void Serializer::writeDecl(const Decl *D) {
auto contextID = addDeclContextRef(extension->getDeclContext());
Type baseTy = extension->getExtendedType();
assert(!baseTy->hasUnboundGenericType());
// FIXME: Use the canonical type here in order to minimize circularity
// issues at deserialization time. A known problematic case here is
@@ -4430,6 +4432,7 @@ void Serializer::writeAST(ModuleOrSourceFile DC,
.push_back({ getKindForTable(D), addDeclRef(D) });
} else if (auto ED = dyn_cast<ExtensionDecl>(D)) {
Type extendedTy = ED->getExtendedType();
assert(!extendedTy->hasUnboundGenericType());
const NominalTypeDecl *extendedNominal = extendedTy->getAnyNominal();
extensionDecls[extendedNominal->getName()]
.push_back({ extendedNominal, addDeclRef(D) });