Skip to content

Commit 4a8e3fc

Browse files
committed
AST: Add VarDecl::isLazyStorageProperty() and set it
1 parent ae4de47 commit 4a8e3fc

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

include/swift/AST/Decl.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ class alignas(1 << DeclAlignInBits) Decl {
370370
IsStatic : 1
371371
);
372372

373-
SWIFT_INLINE_BITFIELD(VarDecl, AbstractStorageDecl, 4+1+1+1+1,
373+
SWIFT_INLINE_BITFIELD(VarDecl, AbstractStorageDecl, 4+1+1+1+1+1,
374374
/// The specifier associated with this variable or parameter. This
375375
/// determines the storage semantics of the value e.g. mutability.
376376
Specifier : 4,
@@ -387,6 +387,8 @@ class alignas(1 << DeclAlignInBits) Decl {
387387
/// It is up to the debugger to instruct SIL how to access this variable.
388388
IsDebuggerVar : 1,
389389

390+
/// Whether this is the backing storage for a lazy property.
391+
IsLazyStorageProperty : 1,
390392

391393
/// Whether this is the backing storage for a property wrapper.
392394
IsPropertyWrapperBackingProperty : 1
@@ -4803,6 +4805,7 @@ class VarDecl : public AbstractStorageDecl {
48034805
Bits.VarDecl.Specifier = static_cast<unsigned>(Sp);
48044806
Bits.VarDecl.IsCaptureList = IsCaptureList;
48054807
Bits.VarDecl.IsDebuggerVar = false;
4808+
Bits.VarDecl.IsLazyStorageProperty = false;
48064809
Bits.VarDecl.HasNonPatternBindingInit = false;
48074810
Bits.VarDecl.IsPropertyWrapperBackingProperty = false;
48084811
}
@@ -5091,6 +5094,13 @@ class VarDecl : public AbstractStorageDecl {
50915094
void setDebuggerVar(bool IsDebuggerVar) {
50925095
Bits.VarDecl.IsDebuggerVar = IsDebuggerVar;
50935096
}
5097+
5098+
/// Is this the synthesized storage for a 'lazy' property?
5099+
bool isLazyStorageProperty() const {
5100+
return Bits.VarDecl.IsLazyStorageProperty;
5101+
}
5102+
void setLazyStorageProperty(bool IsLazyStorage) {
5103+
Bits.VarDecl.IsLazyStorageProperty = IsLazyStorage;
50945104
}
50955105

50965106
/// Retrieve the custom attribute that attaches a property wrapper to this

lib/Sema/CodeSynthesis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,7 @@ void swift::completeLazyVarImplementation(VarDecl *VD) {
16251625
StorageName,
16261626
VD->getDeclContext());
16271627
Storage->setInterfaceType(StorageInterfaceTy);
1628+
Storage->setLazyStorageProperty(true);
16281629
Storage->setUserAccessible(false);
16291630

16301631
// Mark the backing property as 'final'. There's no sensible way to override.

0 commit comments

Comments
 (0)