@@ -679,6 +679,14 @@ void SILGenModule::visitFuncDecl(FuncDecl *fd) { emitFunction(fd); }
679
679
void SILGenModule::emitFunctionDefinition (SILDeclRef constant, SILFunction *f) {
680
680
switch (constant.kind ) {
681
681
case SILDeclRef::Kind::Func: {
682
+ if (auto *ce = constant.getAbstractClosureExpr ()) {
683
+ preEmitFunction (constant, f, ce);
684
+ PrettyStackTraceSILFunction X (" silgen closureexpr" , f);
685
+ SILGenFunction (*this , *f, ce).emitClosure (ce);
686
+ postEmitFunction (constant, f);
687
+ break ;
688
+ }
689
+
682
690
auto *fd = cast<FuncDecl>(constant.getDecl ());
683
691
684
692
preEmitFunction (constant, f, fd);
@@ -1207,10 +1215,8 @@ SILFunction *SILGenModule::emitClosure(AbstractClosureExpr *ce) {
1207
1215
// initializer of the containing type.
1208
1216
if (!f->isExternalDeclaration ())
1209
1217
return f;
1210
- preEmitFunction (constant, f, ce);
1211
- PrettyStackTraceSILFunction X (" silgen closureexpr" , f);
1212
- SILGenFunction (*this , *f, ce).emitClosure (ce);
1213
- postEmitFunction (constant, f);
1218
+
1219
+ emitFunctionDefinition (constant, f);
1214
1220
return f;
1215
1221
}
1216
1222
0 commit comments