Skip to content

Commit cba7a78

Browse files
committed
[AST] Make it possible to check if var decl is for _storage
1 parent 58e330d commit cba7a78

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

include/swift/AST/Decl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5714,6 +5714,11 @@ class VarDecl : public AbstractStorageDecl {
57145714
/// backing property will be treated as the member-initialized property.
57155715
bool isMemberwiseInitialized(bool preferDeclaredProperties) const;
57165716

5717+
/// Check whether this variable presents a local storage synthesized
5718+
/// by the compiler in a user-defined designated initializer to
5719+
/// support initialization of type wrapper managed properties.
5720+
bool isTypeWrapperLocalStorageForInitializer() const;
5721+
57175722
/// Return the range of semantics attributes attached to this VarDecl.
57185723
auto getSemanticsAttrs() const
57195724
-> decltype(getAttrs().getAttributes<SemanticsAttr>()) {

lib/AST/Decl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6504,6 +6504,14 @@ bool VarDecl::isMemberwiseInitialized(bool preferDeclaredProperties) const {
65046504
return true;
65056505
}
65066506

6507+
bool VarDecl::isTypeWrapperLocalStorageForInitializer() const {
6508+
if (auto *ctor =
6509+
dyn_cast_or_null<ConstructorDecl>(getDeclContext()->getAsDecl())) {
6510+
return this == ctor->getLocalTypeWrapperStorageVar();
6511+
}
6512+
return false;
6513+
}
6514+
65076515
bool VarDecl::isLet() const {
65086516
// An awful hack that stabilizes the value of 'isLet' for ParamDecl instances.
65096517
//

0 commit comments

Comments
 (0)