Skip to content

Commit ea05708

Browse files
committed
AST: Eliminate GenericEnvironment::mapConformanceRefIntoContext()
1 parent ec0dfc8 commit ea05708

File tree

5 files changed

+12
-45
lines changed

5 files changed

+12
-45
lines changed

include/swift/AST/GenericEnvironment.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -325,19 +325,6 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
325325
/// abstraction level of their associated type requirements.
326326
SILType mapTypeIntoContext(SILModule &M, SILType type) const;
327327

328-
/// Map an interface type's protocol conformance into the corresponding
329-
/// conformance for the contextual type.
330-
static std::pair<Type, ProtocolConformanceRef>
331-
mapConformanceRefIntoContext(GenericEnvironment *genericEnv,
332-
Type conformingType,
333-
ProtocolConformanceRef conformance);
334-
335-
/// Map an interface type's protocol conformance into the corresponding
336-
/// conformance for the contextual type.
337-
std::pair<Type, ProtocolConformanceRef>
338-
mapConformanceRefIntoContext(Type conformingType,
339-
ProtocolConformanceRef conformance) const;
340-
341328
/// Returns a substitution map that sends every generic parameter to its
342329
/// corresponding archetype in this generic environment.
343330
SubstitutionMap getForwardingSubstitutionMap() const;

lib/AST/GenericEnvironment.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -752,28 +752,6 @@ SubstitutionMap GenericEnvironment::getForwardingSubstitutionMap() const {
752752
MakeAbstractConformanceForGenericType());
753753
}
754754

755-
std::pair<Type, ProtocolConformanceRef>
756-
GenericEnvironment::mapConformanceRefIntoContext(GenericEnvironment *genericEnv,
757-
Type conformingType,
758-
ProtocolConformanceRef conformance) {
759-
if (!genericEnv)
760-
return {conformingType, conformance};
761-
762-
return genericEnv->mapConformanceRefIntoContext(conformingType, conformance);
763-
}
764-
765-
std::pair<Type, ProtocolConformanceRef>
766-
GenericEnvironment::mapConformanceRefIntoContext(
767-
Type conformingInterfaceType,
768-
ProtocolConformanceRef conformance) const {
769-
auto contextConformance = conformance.subst(
770-
QueryInterfaceTypeSubstitutions(this),
771-
LookUpConformanceInModule());
772-
773-
auto contextType = mapTypeIntoContext(conformingInterfaceType);
774-
return {contextType, contextConformance};
775-
}
776-
777755
OpenedElementContext
778756
OpenedElementContext::createForContextualExpansion(ASTContext &ctx,
779757
CanPackExpansionType expansionType) {

lib/IRGen/GenMeta.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,9 +2877,10 @@ namespace {
28772877
substitutions.lookupConformance(underlyingDependentType, P);
28782878

28792879
if (underlyingType->hasTypeParameter()) {
2880-
std::tie(underlyingType, underlyingConformance)
2881-
= GenericEnvironment::mapConformanceRefIntoContext(
2882-
genericEnv, underlyingType, underlyingConformance);
2880+
underlyingType = genericEnv->mapTypeIntoContext(
2881+
underlyingType);
2882+
underlyingConformance = underlyingConformance.subst(
2883+
genericEnv->getForwardingSubstitutionMap());
28832884
}
28842885

28852886
return emitWitnessTableRef(IGF, underlyingType->getCanonicalType(),

lib/SILGen/SILGenExpr.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4144,11 +4144,12 @@ getOrCreateKeyPathEqualsAndHash(SILGenModule &SGM,
41444144

41454145
Type formalTy = index.FormalType;
41464146
ProtocolConformanceRef hashable = index.Hashable;
4147-
std::tie(formalTy, hashable)
4148-
= GenericEnvironment::mapConformanceRefIntoContext(genericEnv,
4149-
formalTy,
4150-
hashable);
4151-
auto formalCanTy = formalTy->getReducedType(genericSig);
4147+
if (genericEnv) {
4148+
formalTy = genericEnv->mapTypeIntoContext(formalTy);
4149+
hashable = hashable.subst(genericEnv->getForwardingSubstitutionMap());
4150+
}
4151+
4152+
auto formalCanTy = formalTy->getCanonicalType();
41524153

41534154
// Get the Equatable conformance from the Hashable conformance.
41544155
auto equatable = hashable.getAssociatedConformance(

lib/Sema/AssociatedTypeInference.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2903,8 +2903,8 @@ bool AssociatedTypeInference::checkCurrentTypeWitnesses(
29032903

29042904
ProtocolConformanceRef conformanceInContext(conformance);
29052905
if (auto *genericEnv = conformance->getGenericEnvironment()) {
2906-
conformanceInContext =
2907-
conformanceInContext.subst(genericEnv->getForwardingSubstitutionMap());
2906+
conformanceInContext = conformanceInContext.subst(
2907+
genericEnv->getForwardingSubstitutionMap());
29082908
}
29092909

29102910
auto substitutions =

0 commit comments

Comments
 (0)