@@ -1626,6 +1626,11 @@ void swift::completeLazyVarImplementation(VarDecl *VD) {
1626
1626
VD->getDeclContext ());
1627
1627
Storage->setInterfaceType (StorageInterfaceTy);
1628
1628
Storage->setUserAccessible (false );
1629
+
1630
+ // Mark the backing property as 'final'. There's no sensible way to override.
1631
+ if (VD->getDeclContext ()->getSelfClassDecl ())
1632
+ makeFinal (Context, Storage);
1633
+
1629
1634
addMemberToContextIfNeeded (Storage, VD->getDeclContext (), VD);
1630
1635
1631
1636
// Create the pattern binding decl for the storage decl. This will get
@@ -1642,12 +1647,7 @@ void swift::completeLazyVarImplementation(VarDecl *VD) {
1642
1647
VD->getGetter ()->setBodySynthesizer (&synthesizeLazyGetterBody, Storage);
1643
1648
VD->getSetter ()->setBodySynthesizer (&synthesizeLazySetterBody, Storage);
1644
1649
1645
- // Mark the vardecl to be final, implicit, and private. In a class, this
1646
- // prevents it from being dynamically dispatched. Note that we do this after
1647
- // the accessors are set up, because we don't want the setter for the lazy
1648
- // property to inherit these properties from the storage.
1649
- if (VD->getDeclContext ()->getSelfClassDecl ())
1650
- makeFinal (Context, Storage);
1650
+ // The storage is implicit and private.
1651
1651
Storage->setImplicit ();
1652
1652
Storage->overwriteAccess (AccessLevel::Private);
1653
1653
Storage->overwriteSetterAccess (AccessLevel::Private);
@@ -1796,6 +1796,15 @@ PropertyWrapperBackingPropertyInfoRequest::evaluate(Evaluator &evaluator,
1796
1796
if (isInvalid)
1797
1797
backingVar->setInvalid ();
1798
1798
backingVar->setOriginalWrappedProperty (var);
1799
+
1800
+ // Mark the backing property as 'final'. There's no sensible way to override.
1801
+ if (dc->getSelfClassDecl ())
1802
+ makeFinal (ctx, backingVar);
1803
+
1804
+ // The backing storage is 'private'.
1805
+ backingVar->overwriteAccess (AccessLevel::Private);
1806
+ backingVar->overwriteSetterAccess (AccessLevel::Private);
1807
+
1799
1808
addMemberToContextIfNeeded (backingVar, dc, var);
1800
1809
1801
1810
// Create the pattern binding declaration for the backing property.
@@ -1819,15 +1828,6 @@ PropertyWrapperBackingPropertyInfoRequest::evaluate(Evaluator &evaluator,
1819
1828
1820
1829
tc.typeCheckPatternBinding (parentPBD, patternNumber);
1821
1830
}
1822
- // Mark the backing property as 'final'. There's no sensible way to override.
1823
- if (dc->getSelfClassDecl ())
1824
- makeFinal (ctx, backingVar);
1825
-
1826
- // The backing storage is 'private'.
1827
- backingVar->overwriteAccess (AccessLevel::Private);
1828
-
1829
- // Determine setter access.
1830
- backingVar->overwriteSetterAccess (AccessLevel::Private);
1831
1831
1832
1832
Expr *originalInitialValue = nullptr ;
1833
1833
if (Expr *init = parentPBD->getInit (patternNumber)) {
0 commit comments