@@ -735,23 +735,40 @@ static Expr *buildStorageReference(AccessorDecl *accessor,
735
735
}
736
736
737
737
bool isMemberLValue = isLValue;
738
+ auto propertyWrapperMutability =
739
+ [&](Decl *decl) -> Optional<std::pair<bool , bool >> {
740
+ if (accessor->isCoroutine ())
741
+ return None;
742
+ auto var = dyn_cast<VarDecl>(decl);
743
+ if (!var)
744
+ return None;
745
+ auto mut = var->getPropertyWrapperMutability ();
746
+ if (!mut)
747
+ return None;
748
+ return std::make_pair (mut->Getter == PropertyWrapperMutability::Mutating,
749
+ mut->Setter == PropertyWrapperMutability::Mutating);
750
+ };
738
751
739
- // If we're acessing a property wrapper, determine if the
752
+ // If we're accessing a property wrapper, determine if the
740
753
// intermediate access requires an lvalue.
741
- if (!accessor->isCoroutine ()) {
742
- if (auto var = dyn_cast<VarDecl>(accessor->getStorage ())) {
743
- if (auto mut = var->getPropertyWrapperMutability ()) {
744
- isMemberLValue = mut->Getter == PropertyWrapperMutability::Mutating;
745
- if (isLValue)
746
- isMemberLValue |= mut->Setter == PropertyWrapperMutability::Mutating;
747
- }
748
- }
754
+ if (auto mut = propertyWrapperMutability (accessor->getStorage ())) {
755
+ isMemberLValue = mut->first ;
756
+ if (isLValue)
757
+ isMemberLValue |= mut->second ;
749
758
}
750
759
751
760
bool isSelfLValue = storage->isGetterMutating ();
752
761
if (isMemberLValue)
753
762
isSelfLValue |= storage->isSetterMutating ();
754
763
764
+ // If we're accessing a property wrapper, determine if
765
+ // the self requires an lvalue.
766
+ if (auto mut = propertyWrapperMutability (storage)) {
767
+ isSelfLValue = mut->first ;
768
+ if (isMemberLValue)
769
+ isSelfLValue |= mut->second ;
770
+ }
771
+
755
772
Expr *selfDRE =
756
773
buildSelfReference (selfDecl, selfAccessKind, isSelfLValue,
757
774
ctx);
0 commit comments