Skip to content

Commit 7244f6c

Browse files
committed
[Typechecker] Synthesize _modify for storage wrapper correctly
1 parent 42473e3 commit 7244f6c

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

lib/Sema/TypeCheckStorage.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ synthesizeSetterBody(AccessorDecl *setter, ASTContext &ctx) {
15251525
return synthesizePropertyWrapperSetterBody(setter, ctx);
15261526
}
15271527

1528-
// Synthesize a getter for the storage wrapper property of a property
1528+
// Synthesize a setter for the storage wrapper property of a property
15291529
// with an attached wrapper.
15301530
if (auto original = var->getOriginalWrappedProperty(
15311531
PropertyWrapperSynthesizedPropertyKind::StorageWrapper)) {
@@ -1571,10 +1571,16 @@ synthesizeCoroutineAccessorBody(AccessorDecl *accessor, ASTContext &ctx) {
15711571
: TargetImpl::Implementation);
15721572

15731573
// If this is a variable with an attached property wrapper, then
1574-
// the accessors need to yield the wrapped value.
1575-
if (isa<VarDecl>(storage) &&
1576-
cast<VarDecl>(storage)->hasAttachedPropertyWrapper()) {
1577-
target = TargetImpl::Wrapper;
1574+
// the accessors need to yield the wrappedValue or projectedValue.
1575+
if (auto var = dyn_cast<VarDecl>(storage)) {
1576+
if (var->hasAttachedPropertyWrapper()) {
1577+
target = TargetImpl::Wrapper;
1578+
}
1579+
1580+
if (var->getOriginalWrappedProperty(
1581+
PropertyWrapperSynthesizedPropertyKind::StorageWrapper)) {
1582+
target = TargetImpl::WrapperStorage;
1583+
}
15781584
}
15791585

15801586
SourceLoc loc = storage->getLoc();

0 commit comments

Comments
 (0)