@@ -463,8 +463,10 @@ getSubstitutionsForCallee(SILModule &M,
463463
464464 // Otherwise, record the replacement and conformances for the mapped
465465 // type.
466- if (isa<GenericTypeParamType>(canTy))
467- subMap.addSubstitution (canTy, sub.getReplacement ());
466+ if (isa<SubstitutableType>(canTy)) {
467+ subMap.addSubstitution (cast<SubstitutableType>(canTy),
468+ sub.getReplacement ());
469+ }
468470 subMap.addConformances (canTy, sub.getConformances ());
469471 }
470472 assert (origSubs.empty ());
@@ -834,7 +836,8 @@ static void getWitnessMethodSubstitutions(
834836 unsigned depth = 0 ;
835837 if (isDefaultWitness) {
836838 // For default witnesses, we substitute all of Self.
837- auto gp = witnessThunkSig->getGenericParams ().front ()->getCanonicalType ();
839+ auto gp = cast<GenericTypeParamType>(witnessThunkSig->getGenericParams ()
840+ .front ()->getCanonicalType ());
838841 subMap.addSubstitution (gp, origSubs.front ().getReplacement ());
839842 subMap.addConformances (gp, origSubs.front ().getConformances ());
840843
@@ -899,8 +902,10 @@ static void getWitnessMethodSubstitutions(
899902 // Otherwise, record the replacement and conformances for the mapped
900903 // type.
901904 auto canTy = mappedDepTy->getCanonicalType ();
902- if (isa<GenericTypeParamType>(canTy))
903- subMap.addSubstitution (canTy, sub.getReplacement ());
905+ if (isa<SubstitutableType>(canTy)) {
906+ subMap.addSubstitution (cast<SubstitutableType>(canTy),
907+ sub.getReplacement ());
908+ }
904909 subMap.addConformances (canTy, sub.getConformances ());
905910 }
906911 assert (subs.empty () && " Did not consume all substitutions" );
0 commit comments