mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Centralize the definition of isMemberwiseInitialized()
This utility was defined in Sema, used in Sema and Index, declared in two headers, and semi- copy-pasted into SILGen. Pull it into VarDecl::isMemberwiseInitialized() and use it consistently.
This commit is contained in:
@@ -5254,6 +5254,30 @@ bool VarDecl::isSelfParameter() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool VarDecl::isMemberwiseInitialized() const {
|
||||
if (!getDeclContext()->isTypeContext())
|
||||
return false;
|
||||
|
||||
// Implicit, computed, and static properties are not initialized.
|
||||
// The exception is lazy properties, which due to batch mode we may or
|
||||
// may not have yet finalized, so they may currently be "stored" or
|
||||
// "computed" in the current AST state.
|
||||
if (isImplicit() || isStatic())
|
||||
return false;
|
||||
|
||||
if (!hasStorage() && !getAttrs().hasAttribute<LazyAttr>() &&
|
||||
!getAttachedPropertyDelegate())
|
||||
return false;
|
||||
|
||||
// Initialized 'let' properties have storage, but don't get an argument
|
||||
// to the memberwise initializer since they already have an initial
|
||||
// value that cannot be overridden.
|
||||
if (isLet() && isParentInitialized())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void VarDecl::setSpecifier(Specifier specifier) {
|
||||
Bits.VarDecl.Specifier = static_cast<unsigned>(specifier);
|
||||
setSupportsMutationIfStillStored(
|
||||
|
||||
Reference in New Issue
Block a user