@@ -3517,6 +3517,32 @@ void TypeChecker::validateDecl(OperatorDecl *OD) {
35173517 }
35183518}
35193519
3520+ static void validateAbstractStorageDecl (AbstractStorageDecl *ASD,
3521+ TypeChecker &TC) {
3522+ if (ASD->hasAccessorFunctions ())
3523+ maybeAddMaterializeForSet (ASD, TC);
3524+
3525+ if (ASD->isFinal ()) {
3526+ makeFinal (TC.Context , ASD->getGetter ());
3527+ makeFinal (TC.Context , ASD->getSetter ());
3528+ makeFinal (TC.Context , ASD->getMaterializeForSetFunc ());
3529+ }
3530+
3531+ if (auto getter = ASD->getGetter ())
3532+ TC.validateDecl (getter);
3533+ if (auto setter = ASD->getSetter ())
3534+ TC.validateDecl (setter);
3535+ if (auto materializeForSet = ASD->getMaterializeForSetFunc ())
3536+ TC.validateDecl (materializeForSet);
3537+ if (ASD->hasAddressors ()) {
3538+ if (auto addressor = ASD->getAddressor ())
3539+ TC.validateDecl (addressor);
3540+ if (auto addressor = ASD->getMutableAddressor ())
3541+ TC.validateDecl (addressor);
3542+ }
3543+
3544+ }
3545+
35203546namespace {
35213547class DeclChecker : public DeclVisitor <DeclChecker> {
35223548public:
@@ -3885,25 +3911,7 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
38853911 inferDynamic (TC.Context , SD);
38863912 }
38873913
3888- if (SD->hasAccessorFunctions ())
3889- maybeAddMaterializeForSet (SD, TC);
3890-
3891- // If this subscript is marked final and has a getter or setter, mark the
3892- // getter and setter as final as well.
3893- if (SD->isFinal ()) {
3894- makeFinal (TC.Context , SD->getGetter ());
3895- makeFinal (TC.Context , SD->getSetter ());
3896- makeFinal (TC.Context , SD->getMaterializeForSetFunc ());
3897- }
3898-
3899- // Make sure the getter and setter have valid types, since they will be
3900- // used by SILGen for any accesses to this subscript.
3901- if (auto getter = SD->getGetter ())
3902- TC.validateDecl (getter);
3903- if (auto setter = SD->getSetter ())
3904- TC.validateDecl (setter);
3905- if (auto materializeForSet = SD->getMaterializeForSetFunc ())
3906- TC.validateDecl (materializeForSet);
3914+ validateAbstractStorageDecl (SD, TC);
39073915
39083916 // If this is a get+mutableAddress property, synthesize the setter body.
39093917 if (SD->getStorageKind () == SubscriptDecl::ComputedWithMutableAddress &&
@@ -7113,25 +7121,11 @@ void TypeChecker::validateDecl(ValueDecl *D) {
71137121 // Synthesize accessors as necessary.
71147122 maybeAddAccessorsToVariable (VD, *this );
71157123
7116- if (VD->hasAccessorFunctions ())
7117- maybeAddMaterializeForSet (VD, *this );
7118-
71197124 // Make sure the getter and setter have valid types, since they will be
71207125 // used by SILGen for any accesses to this variable.
7121- if (auto getter = VD->getGetter ())
7122- validateDecl (getter);
7123- if (auto setter = VD->getSetter ())
7124- validateDecl (setter);
7125- if (auto materializeForSet = VD->getMaterializeForSetFunc ())
7126- validateDecl (materializeForSet);
7127-
7128- // If this variable is marked final and has a getter or setter, mark the
7129- // getter and setter as final as well.
7130- if (VD->isFinal ()) {
7131- makeFinal (Context, VD->getGetter ());
7132- makeFinal (Context, VD->getSetter ());
7133- makeFinal (Context, VD->getMaterializeForSetFunc ());
7134- } else if (VD->isDynamic ()) {
7126+ validateAbstractStorageDecl (VD, *this );
7127+
7128+ if (VD->isDynamic ()) {
71357129 makeDynamic (Context, VD->getGetter ());
71367130 makeDynamic (Context, VD->getSetter ());
71377131 // Skip materializeForSet -- it won't be used with a dynamic property.
0 commit comments