@@ -193,33 +193,21 @@ case TypeKind::Id:
193193
194194 case TypeKind::SILFunction: {
195195 auto fnTy = cast<SILFunctionType>(base);
196- bool changed = false ;
197- auto updateSubs = [&](SubstitutionMap &subs) -> bool {
198- // This interface isn't suitable for doing most transformations on
199- // a substituted SILFunctionType, but it's too hard to come up with
200- // an assertion that meaningfully captures what restrictions are in
201- // place. Generally the restriction that you can't naively substitute
202- // a SILFunctionType using AST mechanisms will have to be good enough.
203- SmallVector<Type, 4 > newReplacements;
204- for (Type type : subs.getReplacementTypes ()) {
205- auto transformed = doIt (type, TypePosition::Invariant);
206- newReplacements.push_back (transformed->getCanonicalType ());
207- if (!type->isEqual (transformed))
208- changed = true ;
209- }
210-
211- if (changed) {
212- subs = SubstitutionMap::get (subs.getGenericSignature (),
213- newReplacements,
214- subs.getConformances ());
215- }
216-
217- return changed;
218- };
219196
220197 if (fnTy->isPolymorphic ())
221198 return fnTy;
222199
200+ auto updateSubs = [&](SubstitutionMap &subs) -> bool {
201+ auto newSubs = asDerived ().transformSubMap (subs);
202+ if (subs && !newSubs)
203+ return false ;
204+ if (subs == newSubs)
205+ return false ;
206+
207+ subs = newSubs;
208+ return true ;
209+ };
210+
223211 if (auto subs = fnTy->getInvocationSubstitutions ()) {
224212 if (updateSubs (subs)) {
225213 return fnTy->withInvocationSubstitutions (subs);
@@ -234,6 +222,8 @@ case TypeKind::Id:
234222 return fnTy;
235223 }
236224
225+ bool changed = false ;
226+
237227 SmallVector<SILParameterInfo, 8 > transInterfaceParams;
238228 for (SILParameterInfo param : fnTy->getParameters ()) {
239229 if (transformSILParameter (pos.flipped (), param, changed))
0 commit comments