@@ -6295,15 +6295,6 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
6295
6295
}
6296
6296
6297
6297
void visitConstructorDecl (ConstructorDecl *CD) {
6298
- if (!IsFirstPass) {
6299
- if (CD->getBody ()) {
6300
- TC.definedFunctions .push_back (CD);
6301
- } else if (requiresDefinition (CD)) {
6302
- // Complain if we should have a body.
6303
- TC.diagnose (CD->getLoc (), diag::missing_initializer_def);
6304
- }
6305
- }
6306
-
6307
6298
if (!IsFirstPass) {
6308
6299
return ;
6309
6300
}
@@ -6352,6 +6343,13 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
6352
6343
6353
6344
TC.checkDeclAttributes (CD);
6354
6345
checkAccessControl (TC, CD);
6346
+
6347
+ if (CD->hasBody () && !CD->isMemberwiseInitializer ()) {
6348
+ TC.definedFunctions .push_back (CD);
6349
+ } else if (requiresDefinition (CD)) {
6350
+ // Complain if we should have a body.
6351
+ TC.diagnose (CD->getLoc (), diag::missing_initializer_def);
6352
+ }
6355
6353
}
6356
6354
6357
6355
void visitDestructorDecl (DestructorDecl *DD) {
@@ -9035,6 +9033,7 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
9035
9033
// We have a designated initializer. Create an override of it.
9036
9034
if (auto ctor = createDesignatedInitOverride (
9037
9035
*this , classDecl, superclassCtor, kind)) {
9036
+ Context.addSynthesizedDecl (ctor);
9038
9037
classDecl->addMember (ctor);
9039
9038
}
9040
9039
}
@@ -9265,6 +9264,9 @@ void TypeChecker::defineDefaultConstructor(NominalTypeDecl *decl) {
9265
9264
// Create an empty body for the default constructor. The type-check of the
9266
9265
// constructor body will introduce default initializations of the members.
9267
9266
ctor->setBody (BraceStmt::create (Context, SourceLoc (), { }, SourceLoc ()));
9267
+
9268
+ // Make sure we type check the constructor later.
9269
+ Context.addSynthesizedDecl (ctor);
9268
9270
}
9269
9271
9270
9272
static void validateAttributes (TypeChecker &TC, Decl *D) {
0 commit comments