Skip to content

Commit 6ca9728

Browse files
committed
[AST] InitAccessors: Mark properties that init other properties as memberwise initializable
1 parent cffc3fd commit 6ca9728

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/AST/Decl.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7132,6 +7132,12 @@ bool VarDecl::isMemberwiseInitialized(bool preferDeclaredProperties) const {
71327132
isBackingStorageForDeclaredProperty(this))
71337133
return false;
71347134

7135+
// If this is a computed property with `init` accessor, it's
7136+
// memberwise initializable when it could be used to initialize
7137+
// other stored properties.
7138+
if (auto *init = getAccessor(AccessorKind::Init))
7139+
return init->getAttrs().hasAttribute<InitializesAttr>();
7140+
71357141
// If this is a computed property, it's not memberwise initialized unless
71367142
// the caller has asked for the declared properties and it is either a
71377143
// `lazy` property or a property with an attached wrapper.

0 commit comments

Comments
 (0)