@@ -1060,19 +1060,41 @@ void SILGenModule::emitDestructor(ClassDecl *cd, DestructorDecl *dd) {
10601060 }
10611061}
10621062
1063- void SILGenModule::emitDefaultArgGenerator (SILDeclRef constant, Expr *arg,
1064- DefaultArgumentKind kind,
1065- DeclContext *initDC) {
1066- switch (kind) {
1063+ void SILGenModule::emitDefaultArgGenerator (SILDeclRef constant,
1064+ ParamDecl *param) {
1065+ auto initDC = param->getDefaultArgumentInitContext ();
1066+
1067+ switch (param->getDefaultArgumentKind ()) {
10671068 case DefaultArgumentKind::None:
10681069 llvm_unreachable (" No default argument here?" );
10691070
1070- case DefaultArgumentKind::Normal:
1071- break ;
1071+ case DefaultArgumentKind::Normal: {
1072+ auto arg = param->getDefaultValue ();
1073+ emitOrDelayFunction (*this , constant,
1074+ [this ,constant,arg,initDC](SILFunction *f) {
1075+ preEmitFunction (constant, arg, f, arg);
1076+ PrettyStackTraceSILFunction X (" silgen emitDefaultArgGenerator " , f);
1077+ SILGenFunction SGF (*this , *f, initDC);
1078+ SGF.emitGeneratorFunction (constant, arg);
1079+ postEmitFunction (constant, f);
1080+ });
1081+ return ;
1082+ }
10721083
1073- case DefaultArgumentKind::Inherited:
1084+ case DefaultArgumentKind::StoredProperty: {
1085+ auto arg = param->getStoredProperty ();
1086+ emitOrDelayFunction (*this , constant,
1087+ [this ,constant,arg,initDC](SILFunction *f) {
1088+ preEmitFunction (constant, arg, f, arg);
1089+ PrettyStackTraceSILFunction X (" silgen emitDefaultArgGenerator " , f);
1090+ SILGenFunction SGF (*this , *f, initDC);
1091+ SGF.emitGeneratorFunction (constant, arg);
1092+ postEmitFunction (constant, f);
1093+ });
10741094 return ;
1095+ }
10751096
1097+ case DefaultArgumentKind::Inherited:
10761098 case DefaultArgumentKind::Column:
10771099 case DefaultArgumentKind::File:
10781100 case DefaultArgumentKind::Line:
@@ -1081,18 +1103,8 @@ void SILGenModule::emitDefaultArgGenerator(SILDeclRef constant, Expr *arg,
10811103 case DefaultArgumentKind::NilLiteral:
10821104 case DefaultArgumentKind::EmptyArray:
10831105 case DefaultArgumentKind::EmptyDictionary:
1084- case DefaultArgumentKind::StoredProperty:
10851106 return ;
10861107 }
1087-
1088- emitOrDelayFunction (*this , constant,
1089- [this ,constant,arg,initDC](SILFunction *f) {
1090- preEmitFunction (constant, arg, f, arg);
1091- PrettyStackTraceSILFunction X (" silgen emitDefaultArgGenerator " , f);
1092- SILGenFunction SGF (*this , *f, initDC);
1093- SGF.emitGeneratorFunction (constant, arg);
1094- postEmitFunction (constant, f);
1095- });
10961108}
10971109
10981110void SILGenModule::
@@ -1161,10 +1173,9 @@ void SILGenModule::emitDefaultArgGenerators(SILDeclRef::Loc decl,
11611173 ParameterList *paramList) {
11621174 unsigned index = 0 ;
11631175 for (auto param : *paramList) {
1164- if (auto defaultArg = param->getDefaultValue ())
1176+ if (param->isDefaultArgument ())
11651177 emitDefaultArgGenerator (SILDeclRef::getDefaultArgGenerator (decl, index),
1166- defaultArg, param->getDefaultArgumentKind (),
1167- param->getDefaultArgumentInitContext ());
1178+ param);
11681179 ++index;
11691180 }
11701181}
0 commit comments