@@ -208,24 +208,21 @@ static ConstructorDecl *findDefaultInit(ASTContext &ctx,
208
208
nominal->lookupQualified (nominal, initName, NL_QualifiedDefault, decls);
209
209
for (const auto &decl : decls) {
210
210
auto init = dyn_cast<ConstructorDecl>(decl);
211
- if (!init || init->getDeclContext () != nominal)
211
+ if (!init || init->getDeclContext () != nominal || init-> isGeneric () )
212
212
continue ;
213
213
214
+ assert (init->hasParameterList ());
214
215
// A constructor which does not have any parameters or where all the
215
216
// parameters have a default argument can be used to default initialize
216
217
// the property wrapper type.
217
- assert (init->hasParameterList ());
218
- auto hasParams = init->getParameters ()->size () > 0 ;
219
- auto allParamsHaveDefaultArg = false ;
220
-
221
- if (hasParams) {
222
- allParamsHaveDefaultArg = llvm::all_of (
223
- init->getParameters ()->getArray (),
224
- [](const ParamDecl *decl) { return decl->isDefaultArgument (); });
225
- }
226
-
227
- // Skip synthesized default initializers
228
- if (!hasParams || (allParamsHaveDefaultArg && !init->isImplicit ())) {
218
+ //
219
+ // A constructor with no parameters will satisfy the check below.
220
+ bool allParamsHaveDefaultArg = llvm::all_of (
221
+ init->getParameters ()->getArray (),
222
+ [](const ParamDecl *decl) { return decl->isDefaultArgument (); });
223
+
224
+ // Only add non-synthesized initializers.
225
+ if (allParamsHaveDefaultArg && !init->isImplicit ()) {
229
226
defaultValueInitializers.push_back (init);
230
227
}
231
228
}
0 commit comments