@@ -342,14 +342,16 @@ IsSetterMutatingRequest::evaluate(Evaluator &evaluator,
342
342
if (auto var = dyn_cast<VarDecl>(storage)) {
343
343
if (auto mut = var->getPropertyWrapperMutability ()) {
344
344
bool isMutating = mut->Setter == PropertyWrapperMutability::Mutating;
345
- if (auto *accessor = var->getParsedAccessor (AccessorKind::DidSet)) {
345
+ if (auto *didSet = var->getParsedAccessor (AccessorKind::DidSet)) {
346
346
// If there's a didSet, we call the getter for the 'oldValue', and so
347
347
// should consider the getter's mutatingness as well
348
- if (!accessor ->isSimpleDidSet ()) {
348
+ if (!didSet ->isSimpleDidSet ()) {
349
349
isMutating |= (mut->Getter == PropertyWrapperMutability::Mutating);
350
350
}
351
- isMutating |= accessor ->getAttrs ().hasAttribute <MutatingAttr>();
351
+ isMutating |= didSet ->getAttrs ().hasAttribute <MutatingAttr>();
352
352
}
353
+ if (auto *willSet = var->getParsedAccessor (AccessorKind::WillSet))
354
+ isMutating |= willSet->getAttrs ().hasAttribute <MutatingAttr>();
353
355
return isMutating && result;
354
356
}
355
357
}
@@ -738,40 +740,39 @@ static Expr *buildStorageReference(AccessorDecl *accessor,
738
740
739
741
// Perform accesses to the wrappedValues along the composition chain.
740
742
if (firstWrapperIdx < lastWrapperIdx) {
741
- if ( auto lvalueness = getPropertyWrapperLValueness (var)) {
742
-
743
- // Figure out if the outermost wrapper instance should be an l-value
744
- bool isLValueForGet = lvalueness-> isLValueForGetAccess [firstWrapperIdx];
745
- bool isLValueForSet = lvalueness-> isLValueForSetAccess [firstWrapperIdx];
746
- isMemberLValue = (isLValueForGet && isUsedForGetAccess) ||
747
- (isLValueForSet && isUsedForSetAccess);
748
-
749
- for (unsigned i : range (firstWrapperIdx, lastWrapperIdx)) {
750
- auto wrapperInfo = var->getAttachedPropertyWrapperTypeInfo (i);
751
- auto wrappedValue = wrapperInfo.valueVar ;
752
-
753
- // Figure out if the wrappedValue accesses should be l-values
754
- bool isWrapperRefLValue = isLValue;
755
- if (i < lastWrapperIdx - 1 ) {
756
- bool isLValueForGet = lvalueness-> isLValueForGetAccess [i+1 ];
757
- bool isLValueForSet = lvalueness-> isLValueForSetAccess [i+1 ];
758
- isWrapperRefLValue = (isLValueForGet && isUsedForGetAccess) ||
759
- (isLValueForSet && isUsedForSetAccess);
760
- }
743
+ auto lvalueness = * getPropertyWrapperLValueness (var);
744
+
745
+ // Figure out if the outermost wrapper instance should be an l-value
746
+ bool isLValueForGet = lvalueness. isLValueForGetAccess [firstWrapperIdx];
747
+ bool isLValueForSet = lvalueness. isLValueForSetAccess [firstWrapperIdx];
748
+ isMemberLValue = (isLValueForGet && isUsedForGetAccess) ||
749
+ (isLValueForSet && isUsedForSetAccess);
750
+
751
+ for (unsigned i : range (firstWrapperIdx, lastWrapperIdx)) {
752
+ auto wrapperInfo = var->getAttachedPropertyWrapperTypeInfo (i);
753
+ auto wrappedValue = wrapperInfo.valueVar ;
754
+
755
+ // Figure out if the wrappedValue accesses should be l-values
756
+ bool isWrapperRefLValue = isLValue;
757
+ if (i < lastWrapperIdx - 1 ) {
758
+ bool isLValueForGet = lvalueness. isLValueForGetAccess [i+1 ];
759
+ bool isLValueForSet = lvalueness. isLValueForSetAccess [i+1 ];
760
+ isWrapperRefLValue = (isLValueForGet && isUsedForGetAccess) ||
761
+ (isLValueForSet && isUsedForSetAccess);
762
+ }
761
763
762
- // Check for availability of wrappedValue.
763
- if (accessor->getAccessorKind () == AccessorKind::Get ||
764
- accessor->getAccessorKind () == AccessorKind::Read) {
765
- if (wrappedValue->getAttrs ().getUnavailable (ctx)) {
766
- diagnoseExplicitUnavailability (
767
- wrappedValue,
768
- var->getAttachedPropertyWrappers ()[i]->getRangeWithAt (),
769
- var->getDeclContext (), nullptr );
770
- }
764
+ // Check for availability of wrappedValue.
765
+ if (accessor->getAccessorKind () == AccessorKind::Get ||
766
+ accessor->getAccessorKind () == AccessorKind::Read) {
767
+ if (wrappedValue->getAttrs ().getUnavailable (ctx)) {
768
+ diagnoseExplicitUnavailability (
769
+ wrappedValue,
770
+ var->getAttachedPropertyWrappers ()[i]->getRangeWithAt (),
771
+ var->getDeclContext (), nullptr );
771
772
}
772
-
773
- underlyingVars.push_back ({ wrappedValue, isWrapperRefLValue });
774
773
}
774
+
775
+ underlyingVars.push_back ({ wrappedValue, isWrapperRefLValue });
775
776
}
776
777
}
777
778
semantics = AccessSemantics::DirectToStorage;
0 commit comments