@@ -231,10 +231,7 @@ class VJPCloner::Implementation final
231
231
extractAllElements (origResult, Builder, origResults);
232
232
233
233
// Get and partially apply the pullback.
234
- auto vjpGenericEnv = vjp->getGenericEnvironment ();
235
- auto vjpSubstMap = vjpGenericEnv
236
- ? vjpGenericEnv->getForwardingSubstitutionMap ()
237
- : vjp->getForwardingSubstitutionMap ();
234
+ auto vjpSubstMap = vjp->getForwardingSubstitutionMap ();
238
235
auto *pullbackRef = Builder.createFunctionRef (loc, pullback);
239
236
240
237
// Prepare partial application arguments.
@@ -257,13 +254,10 @@ class VJPCloner::Implementation final
257
254
auto *pullbackPartialApply = Builder.createPartialApply (
258
255
loc, pullbackRef, vjpSubstMap, {partialApplyArg},
259
256
ParameterConvention::Direct_Guaranteed);
260
- auto pullbackType = vjp->getLoweredFunctionType ()
261
- ->getResults ()
262
- .back ()
263
- .getSILStorageInterfaceType ();
264
- pullbackType = pullbackType.substGenericArgs (
265
- getModule (), vjpSubstMap, TypeExpansionContext::minimal ());
266
- pullbackType = pullbackType.subst (getModule (), vjpSubstMap);
257
+ auto pullbackType = vjp->mapTypeIntoContext (
258
+ vjp->getConventions ().getSILType (
259
+ vjp->getLoweredFunctionType ()->getResults ().back (),
260
+ vjp->getTypeExpansionContext ()));
267
261
auto pullbackFnType = pullbackType.castTo <SILFunctionType>();
268
262
auto pullbackSubstType =
269
263
pullbackPartialApply->getType ().castTo <SILFunctionType>();
0 commit comments