@@ -2685,10 +2685,8 @@ bool AssociatedTypeInference::simplifyCurrentTypeWitnesses() {
2685
2685
abort ();
2686
2686
}
2687
2687
2688
- TypeSubstitutionMap substitutions;
2689
- auto selfTy = cast<SubstitutableType>(
2690
- proto->getSelfInterfaceType ()->getCanonicalType ());
2691
- substitutions[selfTy] = dc->mapTypeIntoContext (conformance->getType ());
2688
+ auto selfTy = proto->getSelfInterfaceType ()->getCanonicalType ();
2689
+ auto substSelfTy = dc->mapTypeIntoContext (conformance->getType ());
2692
2690
2693
2691
for (auto assocType : proto->getAssociatedTypeMembers ()) {
2694
2692
if (conformance->hasTypeWitness (assocType))
@@ -2716,13 +2714,14 @@ bool AssociatedTypeInference::simplifyCurrentTypeWitnesses() {
2716
2714
if (!type->isTypeParameter ())
2717
2715
return std::nullopt;
2718
2716
2719
- auto *rootParam = type->getRootGenericParam ();
2720
- assert (rootParam->isEqual (selfTy));
2721
-
2722
2717
// Replace Self with the concrete conforming type.
2723
- auto substType = Type (type).subst (QueryTypeSubstitutionMap{substitutions},
2724
- LookUpConformanceInModule (),
2725
- options);
2718
+ auto substType = Type (type).subst (
2719
+ [&](SubstitutableType *type) -> Type {
2720
+ ASSERT (type->isEqual (selfTy));
2721
+ return substSelfTy;
2722
+ },
2723
+ LookUpConformanceInModule (),
2724
+ options);
2726
2725
2727
2726
// If we don't have enough type witnesses to substitute fully,
2728
2727
// leave the original type parameter in place.
@@ -2914,12 +2913,12 @@ bool AssociatedTypeInference::checkCurrentTypeWitnesses(
2914
2913
2915
2914
bool AssociatedTypeInference::checkConstrainedExtension (ExtensionDecl *ext) {
2916
2915
auto typeInContext = dc->mapTypeIntoContext (adoptee);
2917
- auto subs = typeInContext->getContextSubstitutions (ext);
2916
+ auto subs = typeInContext->getContextSubstitutionMap (ext-> getExtendedNominal () );
2918
2917
2919
2918
SubstOptions options = getSubstOptionsWithCurrentTypeWitnesses ();
2920
2919
switch (checkRequirements (
2921
2920
ext->getGenericSignature ().getRequirements (),
2922
- QueryTypeSubstitutionMap {subs}, options)) {
2921
+ QuerySubstitutionMap {subs}, options)) {
2923
2922
case CheckRequirementsResult::Success:
2924
2923
case CheckRequirementsResult::SubstitutionFailure:
2925
2924
return false ;
0 commit comments