@@ -5489,12 +5489,13 @@ VarDecl *VarDecl::getPropertyWrapperBackingProperty() const {
5489
5489
return getPropertyWrapperBackingPropertyInfo ().backingVar ;
5490
5490
}
5491
5491
5492
- bool VarDecl::isPropertyWrapperInitializedWithInitialValue () const {
5493
- auto customAttrs = getAttachedPropertyWrappers ();
5492
+ static bool propertyWrapperInitializedViaInitialValue (
5493
+ const VarDecl *var, bool checkDefaultInit) {
5494
+ auto customAttrs = var->getAttachedPropertyWrappers ();
5494
5495
if (customAttrs.empty ())
5495
5496
return false ;
5496
5497
5497
- auto *PBD = getParentPatternBinding ();
5498
+ auto *PBD = var-> getParentPatternBinding ();
5498
5499
if (!PBD)
5499
5500
return false ;
5500
5501
@@ -5509,36 +5510,23 @@ bool VarDecl::isPropertyWrapperInitializedWithInitialValue() const {
5509
5510
return false ;
5510
5511
5511
5512
// Default initialization does not use a value.
5512
- if (getAttachedPropertyWrapperTypeInfo (0 ).defaultInit )
5513
+ if (checkDefaultInit &&
5514
+ var->getAttachedPropertyWrapperTypeInfo (0 ).defaultInit )
5513
5515
return false ;
5514
5516
5515
5517
// If all property wrappers have an initialValue initializer, the property
5516
5518
// wrapper will be initialized that way.
5517
- return allAttachedPropertyWrappersHaveInitialValueInit ();
5519
+ return var-> allAttachedPropertyWrappersHaveInitialValueInit ();
5518
5520
}
5519
5521
5520
- bool VarDecl::isPropertyMemberwiseInitializedWithWrappedType () const {
5521
- auto customAttrs = getAttachedPropertyWrappers ();
5522
- if (customAttrs.empty ())
5523
- return false ;
5524
-
5525
- auto *PBD = getParentPatternBinding ();
5526
- if (!PBD)
5527
- return false ;
5528
-
5529
- // If there was an initializer on the original property, initialize
5530
- // via the initial value.
5531
- if (PBD->getPatternList ()[0 ].getEqualLoc ().isValid ())
5532
- return true ;
5533
-
5534
- // If there was an initializer on the outermost wrapper, initialize
5535
- // via the full wrapper.
5536
- if (customAttrs[0 ]->getArg () != nullptr )
5537
- return false ;
5522
+ bool VarDecl::isPropertyWrapperInitializedWithInitialValue () const {
5523
+ return propertyWrapperInitializedViaInitialValue (
5524
+ this , /* checkDefaultInit=*/ true );
5525
+ }
5538
5526
5539
- // If all property wrappers have an initialValue initializer, the property
5540
- // wrapper will be initialized that way.
5541
- return allAttachedPropertyWrappersHaveInitialValueInit ( );
5527
+ bool VarDecl::isPropertyMemberwiseInitializedWithWrappedType () const {
5528
+ return propertyWrapperInitializedViaInitialValue (
5529
+ this , /* checkDefaultInit= */ false );
5542
5530
}
5543
5531
5544
5532
Identifier VarDecl::getObjCPropertyName () const {
0 commit comments