AST: Move mapTypeOutOfContext() from GenericEnvironment to TypeBase

It doesn't actually *use* the generic environment.
This commit is contained in:
Slava Pestov
2017-11-15 20:37:12 -08:00
parent 28c8fb8b0f
commit f07cde75e7
18 changed files with 65 additions and 91 deletions

View File

@@ -1187,10 +1187,8 @@ void Serializer::writePattern(const Pattern *pattern, DeclContext *owningDC) {
// If we have an owning context and a contextual type, map out to an
// interface type.
if (owningDC && type->hasArchetype()) {
type = owningDC->getGenericEnvironmentOfContext()
->mapTypeOutOfContext(type);
}
if (owningDC && type->hasArchetype())
type = type->mapTypeOutOfContext();
return type;
};
@@ -1621,7 +1619,7 @@ Serializer::writeConformance(ProtocolConformanceRef conformanceRef,
unsigned abbrCode = abbrCodes[SpecializedProtocolConformanceLayout::Code];
auto type = conf->getType();
if (genericEnv && type->hasArchetype())
type = genericEnv->mapTypeOutOfContext(type);
type = type->mapTypeOutOfContext();
SpecializedProtocolConformanceLayout::emitRecord(Out, ScratchRecord,
abbrCode,
addTypeRef(type),
@@ -1639,7 +1637,7 @@ Serializer::writeConformance(ProtocolConformanceRef conformanceRef,
auto type = conf->getType();
if (genericEnv && type->hasArchetype())
type = genericEnv->mapTypeOutOfContext(type);
type = type->mapTypeOutOfContext();
InheritedProtocolConformanceLayout::emitRecord(
Out, ScratchRecord, abbrCode, addTypeRef(type));
@@ -1678,8 +1676,7 @@ Serializer::writeSubstitutions(SubstitutionList substitutions,
for (auto &sub : substitutions) {
auto replacementType = sub.getReplacement();
if (genericEnv && replacementType->hasArchetype()) {
replacementType =
genericEnv->mapTypeOutOfContext(replacementType);
replacementType = replacementType->mapTypeOutOfContext();
}
BoundGenericSubstitutionLayout::emitRecord(