@@ -1225,9 +1225,8 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1225
1225
auto captureInfo = SGF.SGM.Types.getLoweredLocalCaptures(constant);
1226
1226
SGF.SGM.Types.setCaptureTypeExpansionContext(constant, SGF.SGM.M);
1227
1227
1228
- if (afd->getDeclContext()->isLocalContext() &&
1229
- !captureInfo.hasGenericParamCaptures())
1230
- subs = SubstitutionMap();
1228
+ subs = SGF.SGM.Types.getSubstitutionMapWithCapturedEnvironments(
1229
+ constant, captureInfo, subs);
1231
1230
1232
1231
// Check whether we have to dispatch to the original implementation of a
1233
1232
// dynamically_replaceable inside of a dynamic_replacement(for:) function.
@@ -1304,17 +1303,14 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1304
1303
1305
1304
// A directly-called closure can be emitted as a direct call instead of
1306
1305
// really producing a closure object.
1307
-
1308
- auto captureInfo = SGF.SGM.M.Types.getLoweredLocalCaptures(constant);
1309
-
1310
1306
SubstitutionMap subs;
1311
- if (captureInfo.hasGenericParamCaptures() )
1312
- subs = SGF.getForwardingSubstitutionMap( );
1307
+ std::tie(std::ignore, std::ignore, subs )
1308
+ = SGF.SGM.Types.getForwardingSubstitutionsForLowering(constant );
1313
1309
1314
1310
setCallee(Callee::forDirect(SGF, constant, subs, e));
1315
1311
1316
1312
// If the closure requires captures, emit them.
1317
- if (!captureInfo.getCaptures().empty( )) {
1313
+ if (SGF.SGM.Types.hasLoweredLocalCaptures(constant )) {
1318
1314
SmallVector<ManagedValue, 4> captures;
1319
1315
SGF.emitCaptures(e, constant, CaptureEmission::ImmediateApplication,
1320
1316
captures);
@@ -6712,14 +6708,9 @@ static Callee getBaseAccessorFunctionRef(SILGenFunction &SGF,
6712
6708
subs, loc, true);
6713
6709
}
6714
6710
6715
- // The accessor might be a local function that does not capture any
6716
- // generic parameters, in which case we don't want to pass in any
6717
- // substitutions.
6718
6711
auto captureInfo = SGF.SGM.Types.getLoweredLocalCaptures(constant);
6719
- if (decl->getDeclContext()->isLocalContext() &&
6720
- !captureInfo.hasGenericParamCaptures()) {
6721
- subs = SubstitutionMap();
6722
- }
6712
+ subs = SGF.SGM.Types.getSubstitutionMapWithCapturedEnvironments(
6713
+ constant, captureInfo, subs);
6723
6714
6724
6715
// If this is a method in a protocol, generate it as a protocol call.
6725
6716
if (isa<ProtocolDecl>(decl->getDeclContext())) {
0 commit comments