@@ -193,33 +193,21 @@ case TypeKind::Id:
193
193
194
194
case TypeKind::SILFunction: {
195
195
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
- };
219
196
220
197
if (fnTy->isPolymorphic ())
221
198
return fnTy;
222
199
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
+
223
211
if (auto subs = fnTy->getInvocationSubstitutions ()) {
224
212
if (updateSubs (subs)) {
225
213
return fnTy->withInvocationSubstitutions (subs);
@@ -234,6 +222,8 @@ case TypeKind::Id:
234
222
return fnTy;
235
223
}
236
224
225
+ bool changed = false ;
226
+
237
227
SmallVector<SILParameterInfo, 8 > transInterfaceParams;
238
228
for (SILParameterInfo param : fnTy->getParameters ()) {
239
229
if (transformSILParameter (pos.flipped (), param, changed))
0 commit comments