Skip to content

Commit 765618b

Browse files
committed
[NFC] Update the documentation for/in buildStorageReference using
the description from swiftlang#29069
1 parent 8785454 commit 765618b

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/Sema/TypeCheckStorage.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,16 @@ getPropertyWrapperLValueness(VarDecl *var) {
607607
/// Build a reference to the storage of a declaration. Returns nullptr if there
608608
/// was an error. This should only occur if an invalid declaration was type
609609
/// checked; another diagnostic should have been emitted already.
610+
///
611+
/// The resulting reference is used in synthesized property accessors and is of
612+
/// one of the following forms:
613+
/// 1. Without property wrappers:
614+
/// - Stored: \c self.member
615+
/// 2. With property wrappers:
616+
/// - Wrapped: \c self._member.wrappedValue
617+
/// - Composition: \c self._member.wrappedValue.wrappedValue….wrappedValue
618+
/// - Projected: \c self._member.projectedValue
619+
/// - Enclosed instance: \c Wrapper[_enclosedInstance: self, …]
610620
static Expr *buildStorageReference(AccessorDecl *accessor,
611621
AbstractStorageDecl *storage,
612622
TargetImpl target,
@@ -618,6 +628,8 @@ static Expr *buildStorageReference(AccessorDecl *accessor,
618628
// Local function to "finish" the expression, creating a member reference
619629
// to the given sequence of underlying variables.
620630
Optional<EnclosingSelfPropertyWrapperAccess> enclosingSelfAccess;
631+
// Contains the underlying wrappedValue declaration in a property wrapper
632+
// along with whether or not the reference to this field needs to be an lvalue
621633
llvm::SmallVector<std::pair<VarDecl *, bool>, 1> underlyingVars;
622634
auto finish = [&](Expr *result) -> Expr * {
623635
for (auto underlyingVarPair : underlyingVars) {
@@ -1755,9 +1767,9 @@ synthesizeCoroutineAccessorBody(AccessorDecl *accessor, ASTContext &ctx) {
17551767

17561768
// Build a reference to the storage.
17571769
Expr *ref = buildStorageReference(accessor, storage, target,
1758-
/*isUsedForGetAccess=*/true,
1759-
/*isUsedForSetAccess=*/isModify,
1760-
ctx);
1770+
/*isUsedForGetAccess=*/true,
1771+
/*isUsedForSetAccess=*/isModify,
1772+
ctx);
17611773
if (ref != nullptr) {
17621774
// Wrap it with an `&` marker if this is a modify.
17631775
ref = maybeWrapInOutExpr(ref, ctx);

0 commit comments

Comments
 (0)