Serialization: Don't crash when serializing conformances with interface types in them

This commit is contained in:
Slava Pestov
2017-04-17 18:19:05 -06:00
parent cc611de2aa
commit a3f725ac2f

View File

@@ -1394,7 +1394,7 @@ Serializer::writeConformance(ProtocolConformanceRef conformanceRef,
auto substitutions = conf->getGenericSubstitutions();
unsigned abbrCode = abbrCodes[SpecializedProtocolConformanceLayout::Code];
auto type = conf->getType();
if (genericEnv)
if (genericEnv && type->hasArchetype())
type = genericEnv->mapTypeOutOfContext(type);
SpecializedProtocolConformanceLayout::emitRecord(Out, ScratchRecord,
abbrCode,
@@ -1412,7 +1412,7 @@ Serializer::writeConformance(ProtocolConformanceRef conformanceRef,
= abbrCodes[InheritedProtocolConformanceLayout::Code];
auto type = conf->getType();
if (genericEnv)
if (genericEnv && type->hasArchetype())
type = genericEnv->mapTypeOutOfContext(type);
InheritedProtocolConformanceLayout::emitRecord(
@@ -1451,7 +1451,7 @@ Serializer::writeSubstitutions(SubstitutionList substitutions,
for (auto &sub : substitutions) {
auto replacementType = sub.getReplacement();
if (genericEnv) {
if (genericEnv && replacementType->hasArchetype()) {
replacementType =
genericEnv->mapTypeOutOfContext(replacementType);
}