Skip to content

Commit 4ba1833

Browse files
committed
[TBDGen] Emit property wrapper backing initializer symbol
1 parent 81c0a0e commit 4ba1833

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/TBDGen/TBDGen.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/AST/ASTVisitor.h"
2222
#include "swift/AST/Module.h"
2323
#include "swift/AST/ParameterList.h"
24+
#include "swift/AST/PropertyWrappers.h"
2425
#include "swift/Basic/LLVM.h"
2526
#include "swift/IRGen/Linking.h"
2627
#include "swift/SIL/FormalLinkage.h"
@@ -309,8 +310,17 @@ void TBDGenVisitor::visitVarDecl(VarDecl *VD) {
309310
if (VD->isLazilyInitializedGlobal())
310311
addSymbol(SILDeclRef(VD, SILDeclRef::Kind::GlobalAccessor));
311312
}
313+
312314
}
313315

316+
// Wrapped non-static member properties may have a backing initializer.
317+
if (auto wrapperInfo = VD->getPropertyWrapperBackingPropertyInfo()) {
318+
if (wrapperInfo.initializeFromOriginal && !VD->isStatic()) {
319+
addSymbol(
320+
SILDeclRef(VD, SILDeclRef::Kind::PropertyWrapperBackingInitializer));
321+
}
322+
};
323+
314324
visitAbstractStorageDecl(VD);
315325
}
316326

test/TBD/property_wrapper.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-ir -o/dev/null -parse-as-library -module-name test -validate-tbd-against-ir=all %s
2+
3+
@propertyWrapper
4+
public struct Wrapper<Value> {
5+
public var wrappedValue: Value
6+
7+
public init(wrappedValue: Value) {
8+
self.wrappedValue = wrappedValue
9+
}
10+
}
11+
12+
public struct UseWrapper {
13+
@Wrapper public var string = "hello"
14+
}
15+

0 commit comments

Comments
 (0)