@@ -743,8 +743,6 @@ static Expr *buildStorageReference(AccessorDecl *accessor,
743
743
bool isMemberLValue = isLValue;
744
744
auto propertyWrapperMutability =
745
745
[&](Decl *decl) -> Optional<std::pair<bool , bool >> {
746
- if (accessor->isCoroutine ())
747
- return None;
748
746
auto var = dyn_cast<VarDecl>(decl);
749
747
if (!var)
750
748
return None;
@@ -1572,6 +1570,13 @@ synthesizeCoroutineAccessorBody(AccessorDecl *accessor, ASTContext &ctx) {
1572
1570
? TargetImpl::Ordinary
1573
1571
: TargetImpl::Implementation);
1574
1572
1573
+ // 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;
1578
+ }
1579
+
1575
1580
SourceLoc loc = storage->getLoc ();
1576
1581
SmallVector<ASTNode, 1 > body;
1577
1582
@@ -1602,8 +1607,11 @@ synthesizeReadCoroutineBody(AccessorDecl *read, ASTContext &ctx) {
1602
1607
static std::pair<BraceStmt *, bool >
1603
1608
synthesizeModifyCoroutineBody (AccessorDecl *modify, ASTContext &ctx) {
1604
1609
#ifndef NDEBUG
1605
- auto impl = modify->getStorage ()->getReadWriteImpl ();
1606
- assert (impl != ReadWriteImplKind::Modify &&
1610
+ auto storage = modify->getStorage ();
1611
+ auto impl = storage->getReadWriteImpl ();
1612
+ auto hasWrapper = isa<VarDecl>(storage) &&
1613
+ cast<VarDecl>(storage)->hasAttachedPropertyWrapper ();
1614
+ assert ((hasWrapper || impl != ReadWriteImplKind::Modify) &&
1607
1615
impl != ReadWriteImplKind::Immutable);
1608
1616
#endif
1609
1617
return synthesizeCoroutineAccessorBody (modify, ctx);
@@ -2548,7 +2556,8 @@ static void finishPropertyWrapperImplInfo(VarDecl *var,
2548
2556
}
2549
2557
2550
2558
if (wrapperSetterIsUsable)
2551
- info = StorageImplInfo::getMutableComputed ();
2559
+ info = StorageImplInfo (ReadImplKind::Get, WriteImplKind::Set,
2560
+ ReadWriteImplKind::Modify);
2552
2561
else
2553
2562
info = StorageImplInfo::getImmutableComputed ();
2554
2563
}
0 commit comments