@@ -68,9 +68,9 @@ SubstitutionMap SILGenModule::mapSubstitutionsForWitnessOverride(
68
68
// / Return the abstraction pattern to use when calling a function value.
69
69
static AbstractionPattern
70
70
getIndirectApplyAbstractionPattern (SILGenFunction &SGF,
71
+ AbstractionPattern pattern,
71
72
CanFunctionType fnType) {
72
73
assert (fnType);
73
- AbstractionPattern pattern (fnType);
74
74
switch (fnType->getRepresentation ()) {
75
75
case FunctionTypeRepresentation::Swift:
76
76
case FunctionTypeRepresentation::Thin:
@@ -875,9 +875,9 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
875
875
876
876
ManagedValue fn = SGF.emitRValueAsSingleValue (e);
877
877
auto substType = cast<FunctionType>(e->getType ()->getCanonicalType ());
878
-
878
+ auto origType = AbstractionPattern (substType);
879
879
// When calling an C or block function, there's implicit bridging.
880
- auto origType = getIndirectApplyAbstractionPattern (SGF, substType);
880
+ origType = getIndirectApplyAbstractionPattern (SGF, origType , substType);
881
881
882
882
setCallee (Callee::forIndirect (fn, origType, substType, e));
883
883
}
@@ -1182,10 +1182,6 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1182
1182
}
1183
1183
1184
1184
void visitMemberRefExpr (MemberRefExpr *e) {
1185
- // If we're loading a closure-type property out of a generic aggregate,
1186
- // we might reabstract it under normal circumstances, but since we're
1187
- // going to apply it immediately here, there's no reason to. We can
1188
- // invoke the function value at whatever abstraction level we get.
1189
1185
assert (isa<VarDecl>(e->getMember ().getDecl ()));
1190
1186
1191
1187
// Any writebacks for this access are tightly scoped.
@@ -1197,9 +1193,12 @@ class SILGenApply : public Lowering::ExprVisitor<SILGenApply> {
1197
1193
1198
1194
ManagedValue fn = SGF.emitLoadOfLValue (e, std::move (lv), SGFContext ())
1199
1195
.getAsSingleValue (SGF, e);
1200
-
1201
- setCallee (Callee::forIndirect (fn, lv.getOrigFormalType (),
1202
- cast<FunctionType>(lv.getSubstFormalType ()), e));
1196
+ auto substType = cast<FunctionType>(lv.getSubstFormalType ());
1197
+ auto origType = lv.getOrigFormalType ();
1198
+ // When calling an C or block function, there's implicit bridging.
1199
+ origType = getIndirectApplyAbstractionPattern (SGF, origType, substType);
1200
+
1201
+ setCallee (Callee::forIndirect (fn, origType, substType, e));
1203
1202
}
1204
1203
1205
1204
void visitAbstractClosureExpr (AbstractClosureExpr *e) {
0 commit comments