mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Refactor GenericParamList::getSubstitutionMap() to take a GenericSignature, NFC
This function takes a substitution array and produces a contextual type substitution map, so it is the contextual type equivalent of GenericSignature::getSubstitutionMap(), which produces an interface type substitution map. The new version takes a GenericSignature, just like the new getForwardingSubstitutions(), so that it can walk the requirements of the signature rather than walking the AllArchetypes list. Also, this new version now produces a mapping from archetypes to conformances in addition to the type mapping, which will allow it to be used in a few places that had hand-coded logic.
This commit is contained in:
@@ -358,16 +358,33 @@ SpecializedProtocolConformance::getTypeWitnessSubstAndDecl(
|
||||
}
|
||||
|
||||
// Otherwise, perform substitutions to create this witness now.
|
||||
TypeSubstitutionMap substitutionMap = GenericConformance->getGenericParams()
|
||||
->getSubstitutionMap(GenericSubstitutions);
|
||||
auto conformingDC = getDeclContext();
|
||||
auto conformingModule = conformingDC->getParentModule();
|
||||
|
||||
auto *genericParams = GenericConformance->getGenericParams();
|
||||
auto *genericSig = GenericConformance->getGenericSignature();
|
||||
|
||||
TypeSubstitutionMap substitutionMap;
|
||||
|
||||
// FIXME: We could have a new version of Type::subst() that
|
||||
// takes a conformanceMap in addition to a substitutionMap,
|
||||
// but for now this is ignored below
|
||||
ArchetypeConformanceMap conformanceMap;
|
||||
|
||||
// Compute a context type substitution map from the
|
||||
// substitution array stored in this conformance
|
||||
genericParams->getSubstitutionMap(conformingModule, genericSig,
|
||||
GenericSubstitutions,
|
||||
substitutionMap,
|
||||
conformanceMap);
|
||||
|
||||
auto genericWitnessAndDecl
|
||||
= GenericConformance->getTypeWitnessSubstAndDecl(assocType, resolver);
|
||||
|
||||
auto &genericWitness = genericWitnessAndDecl.first;
|
||||
auto *typeDecl = genericWitnessAndDecl.second;
|
||||
auto conformingDC = getDeclContext();
|
||||
auto conformingModule = conformingDC->getParentModule();
|
||||
|
||||
// Apply the substitution we computed above
|
||||
auto specializedType
|
||||
= genericWitness.getReplacement().subst(conformingModule, substitutionMap,
|
||||
None);
|
||||
|
||||
Reference in New Issue
Block a user