Skip to content

Commit f2582e1

Browse files
committed
AST: Replace a few mapTypeOutOfContext() calls with ArchetypeType::getInterfaceType()
1 parent 9c0de31 commit f2582e1

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,7 @@ void ASTMangler::appendType(Type type) {
892892

893893
// Find the archetype information.
894894
const DeclContext *DC = DeclCtx;
895-
auto GTPT = GenericEnvironment::mapTypeOutOfContext(GenericEnv, archetype)
896-
->castTo<GenericTypeParamType>();
895+
auto GTPT = archetype->getInterfaceType()->castTo<GenericTypeParamType>();
897896

898897
// The DWARF output created by Swift is intentionally flat,
899898
// therefore archetypes are emitted with their DeclContext if

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2685,8 +2685,7 @@ void ArchetypeType::resolveNestedType(
26852685
auto genericEnv = getGenericEnvironment();
26862686
auto &builder = *genericEnv->getGenericSignatureBuilder();
26872687

2688-
Type interfaceType =
2689-
genericEnv->mapTypeOutOfContext(const_cast<ArchetypeType *>(this));
2688+
Type interfaceType = getInterfaceType();
26902689
Type memberInterfaceType =
26912690
DependentMemberType::get(interfaceType, nested.first);
26922691
auto equivClass =

lib/AST/SubstitutionMap.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ Type SubstitutionMap::lookupSubstitution(CanSubstitutableType type) const {
106106
archetype->getParent() != nullptr)
107107
return Type();
108108

109-
auto *genericEnv = archetype->getGenericEnvironment();
110109
type = cast<GenericTypeParamType>(
111-
genericEnv->mapTypeOutOfContext(archetype)->getCanonicalType());
110+
archetype->getInterfaceType()->getCanonicalType());
112111
}
113112

114113
// Find the index of the replacement type based on the generic parameter we
@@ -168,8 +167,7 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
168167
// If we have an archetype, map out of the context so we can compute a
169168
// conformance access path.
170169
if (auto archetype = dyn_cast<ArchetypeType>(type)) {
171-
auto *genericEnv = archetype->getGenericEnvironment();
172-
type = genericEnv->mapTypeOutOfContext(type)->getCanonicalType();
170+
type = archetype->getInterfaceType()->getCanonicalType();
173171
}
174172

175173
// Error path: if we don't have a type parameter, there is no conformance.

0 commit comments

Comments
 (0)