@@ -4373,6 +4373,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4373
4373
4374
4374
TC.validateDecl (ED);
4375
4375
TC.DeclsToFinalize .remove (ED);
4376
+ ED->setHasValidatedLayout ();
4376
4377
4377
4378
{
4378
4379
// Check for circular inheritance of the raw type.
@@ -4406,6 +4407,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4406
4407
4407
4408
TC.validateDecl (SD);
4408
4409
TC.DeclsToFinalize .remove (SD);
4410
+ SD->setHasValidatedLayout ();
4409
4411
4410
4412
TC.addImplicitConstructors (SD);
4411
4413
@@ -4531,6 +4533,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
4531
4533
TC.validateDecl (CD);
4532
4534
TC.requestSuperclassLayout (CD);
4533
4535
TC.DeclsToFinalize .remove (CD);
4536
+ CD->setHasValidatedLayout ();
4534
4537
4535
4538
{
4536
4539
// Check for circular inheritance.
@@ -6910,7 +6913,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
6910
6913
}
6911
6914
6912
6915
if (!isa<ClassDecl>(nominal))
6913
- DeclsToFinalize. insert (nominal);
6916
+ requestNominalLayout (nominal);
6914
6917
6915
6918
break ;
6916
6919
}
@@ -7732,7 +7735,7 @@ void TypeChecker::validateDecl(ValueDecl *D) {
7732
7735
}
7733
7736
7734
7737
// Member subscripts need some special validation logic.
7735
- if (auto nominalDecl = dc->getAsNominalTypeOrNominalTypeExtensionContext ()) {
7738
+ if (dc->isTypeContext ()) {
7736
7739
// If this is a class member, mark it final if the class is final.
7737
7740
inferFinalAndDiagnoseIfNeeded (*this , SD, StaticSpellingKind::None);
7738
7741
@@ -7988,8 +7991,6 @@ static void finalizeType(TypeChecker &TC, NominalTypeDecl *nominal) {
7988
7991
assert (!nominal->hasClangNode ());
7989
7992
assert (isa<SourceFile>(nominal->getModuleScopeContext ()));
7990
7993
7991
- Optional<bool > lazyVarsAlreadyHaveImplementation;
7992
-
7993
7994
if (auto *classDecl = dyn_cast<ClassDecl>(nominal))
7994
7995
TC.requestSuperclassLayout (classDecl);
7995
7996
@@ -8004,31 +8005,14 @@ static void finalizeType(TypeChecker &TC, NominalTypeDecl *nominal) {
8004
8005
TC.validateDecl (VD);
8005
8006
8006
8007
// The only thing left to do is synthesize storage for lazy variables.
8007
- // We only have to do that if it's a type from another file, though.
8008
- // In NDEBUG builds, bail out as soon as we can.
8009
- #ifdef NDEBUG
8010
- if (lazyVarsAlreadyHaveImplementation.hasValue () &&
8011
- lazyVarsAlreadyHaveImplementation.getValue ())
8012
- continue ;
8013
- #endif
8014
8008
auto *prop = dyn_cast<VarDecl>(D);
8015
8009
if (!prop)
8016
8010
continue ;
8017
8011
8018
8012
if (prop->getAttrs ().hasAttribute <LazyAttr>() && !prop->isStatic ()
8019
8013
&& prop->getGetter ()) {
8020
- bool hasImplementation = prop->getGetter ()->hasBody ();
8021
-
8022
- if (lazyVarsAlreadyHaveImplementation.hasValue ()) {
8023
- assert (lazyVarsAlreadyHaveImplementation.getValue () ==
8024
- hasImplementation &&
8025
- " only some lazy vars already have implementations" );
8026
- } else {
8027
- lazyVarsAlreadyHaveImplementation = hasImplementation;
8028
- }
8029
-
8030
- if (!hasImplementation)
8031
- TC.completeLazyVarImplementation (prop);
8014
+ assert (!prop->getGetter ()->hasBody ());
8015
+ TC.completeLazyVarImplementation (prop);
8032
8016
}
8033
8017
}
8034
8018
0 commit comments