[Serialization] Preserve the decl context for a NormalProtocolConformance.

Doug had changed the comment but not the implementation -- we were still
serializing the containing module rather than the declaring nominal or
extension.

Found by enabling verification on deserialized decls (to come soon).

Swift SVN r22198
This commit is contained in:
Jordan Rose
2014-09-23 02:06:24 +00:00
parent a5685d6dac
commit 7fe346a091
3 changed files with 8 additions and 6 deletions

View File

@@ -145,6 +145,9 @@ DeclID Serializer::addDeclRef(const Decl *D, bool forceSerialization) {
return id.first;
}
assert((!isDeclXRef(D) || isa<ValueDecl>(D) || isa<OperatorDecl>(D)) &&
"cannot cross-reference this decl");
// Record any generic parameters that come from this decl, so that we can use
// the decl to refer to the parameters later.
const GenericParamList *paramList = nullptr;
@@ -825,9 +828,9 @@ Serializer::writeConformance(const ProtocolDecl *protocol,
unsigned numInheritedConformances = conf->getInheritedConformances().size();
unsigned abbrCode
= abbrCodes[NormalProtocolConformanceLayout::Code];
auto moduleID = addModuleRef(conf->getDeclContext()->getParentModule());
auto ownerID = addDeclRef(getDeclForContext(conf->getDeclContext()));
NormalProtocolConformanceLayout::emitRecord(Out, ScratchRecord, abbrCode,
addDeclRef(protocol), moduleID,
addDeclRef(protocol), ownerID,
numValueWitnesses,
numTypeWitnesses,
numInheritedConformances,