@@ -1496,7 +1496,7 @@ static void checkVarBehavior(VarDecl *decl, TypeChecker &TC) {
1496
1496
// No behavior, no problems.
1497
1497
if (!decl->hasBehavior ())
1498
1498
return ;
1499
-
1499
+
1500
1500
// Don't try to check the behavior if we already encountered an error.
1501
1501
if (decl->getType ()->hasError ())
1502
1502
return ;
@@ -2262,9 +2262,6 @@ static void validateAbstractStorageDecl(TypeChecker &TC,
2262
2262
storage->setIsGetterMutating (computeIsGetterMutating (TC, storage));
2263
2263
storage->setIsSetterMutating (computeIsSetterMutating (TC, storage));
2264
2264
2265
- // Add any mandatory accessors now.
2266
- maybeAddAccessorsToStorage (TC, storage);
2267
-
2268
2265
// Everything else about the accessors can wait until finalization.
2269
2266
// This will validate all the accessors.
2270
2267
TC.DeclsToFinalize .insert (storage);
@@ -2274,9 +2271,15 @@ static void finalizeAbstractStorageDecl(TypeChecker &TC,
2274
2271
AbstractStorageDecl *storage) {
2275
2272
TC.validateDecl (storage);
2276
2273
2274
+ // Add any mandatory accessors now.
2275
+ maybeAddAccessorsToStorage (TC, storage);
2276
+
2277
2277
for (auto accessor : storage->getAllAccessors ()) {
2278
2278
// Are there accessors we can safely ignore here, like maybe observers?
2279
2279
TC.validateDecl (accessor);
2280
+
2281
+ // Finalize the accessors as well.
2282
+ TC.DeclsToFinalize .insert (accessor);
2280
2283
}
2281
2284
}
2282
2285
@@ -2373,6 +2376,9 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2373
2376
void visitBoundVariable (VarDecl *VD) {
2374
2377
TC.validateDecl (VD);
2375
2378
2379
+ // Set up accessors.
2380
+ maybeAddAccessorsToStorage (TC, VD);
2381
+
2376
2382
// Check the behavior.
2377
2383
checkVarBehavior (VD, TC);
2378
2384
@@ -4606,6 +4612,7 @@ void TypeChecker::requestMemberLayout(ValueDecl *member) {
4606
4612
// because if they never get validated at all then conformance checkers
4607
4613
// will complain about selector mismatches.
4608
4614
if (storage->isObjC ()) {
4615
+ maybeAddAccessorsToStorage (*this , storage);
4609
4616
for (auto accessor : storage->getAllAccessors ()) {
4610
4617
requestMemberLayout (accessor);
4611
4618
}
0 commit comments