@@ -797,23 +797,35 @@ llvm::Expected<bool> AreAllStoredPropertiesDefaultInitableRequest::evaluate(
797
797
// synthesize an initial value (e.g. for an optional) then we suppress
798
798
// generation of the default initializer.
799
799
if (auto pbd = dyn_cast<PatternBindingDecl>(member)) {
800
- if (pbd->hasStorage () && !pbd->isStatic ()) {
801
- for (auto idx : range (pbd->getNumPatternEntries ())) {
802
- if (pbd->isInitialized (idx)) continue ;
800
+ // Static variables are irrelevant.
801
+ if (pbd->isStatic ()) {
802
+ continue ;
803
+ }
803
804
805
+ for (auto idx : range (pbd->getNumPatternEntries ())) {
806
+ bool HasStorage = false ;
807
+ bool CheckDefaultInitializer = true ;
808
+ pbd->getPattern (idx)->forEachVariable ([&](VarDecl *VD) {
804
809
// If one of the bound variables is @NSManaged, go ahead no matter
805
810
// what.
806
- bool CheckDefaultInitializer = true ;
807
- pbd->getPattern (idx)->forEachVariable ([&](VarDecl *vd) {
808
- if (vd->getAttrs ().hasAttribute <NSManagedAttr>())
809
- CheckDefaultInitializer = false ;
810
- });
811
-
812
- // If we cannot default initialize the property, we cannot
813
- // synthesize a default initializer for the class.
814
- if (CheckDefaultInitializer && !pbd->isDefaultInitializable ())
815
- return false ;
816
- }
811
+ if (VD->getAttrs ().hasAttribute <NSManagedAttr>())
812
+ CheckDefaultInitializer = false ;
813
+
814
+ if (VD->hasStorage ())
815
+ HasStorage = true ;
816
+ auto *backing = VD->getPropertyWrapperBackingProperty ();
817
+ if (backing && backing->hasStorage ())
818
+ HasStorage = true ;
819
+ });
820
+
821
+ if (!HasStorage) continue ;
822
+
823
+ if (pbd->isInitialized (idx)) continue ;
824
+
825
+ // If we cannot default initialize the property, we cannot
826
+ // synthesize a default initializer for the class.
827
+ if (CheckDefaultInitializer && !pbd->isDefaultInitializable ())
828
+ return false ;
817
829
}
818
830
}
819
831
}
0 commit comments