Skip to content

Commit 216ae87

Browse files
committed
[Typechecker] Wrapped properties with observers should not have ReadWriteImplKind::Modify
1 parent 3999b8b commit 216ae87

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/Sema/TypeCheckStorage.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,11 +2683,19 @@ static void finishPropertyWrapperImplInfo(VarDecl *var,
26832683
}
26842684
}
26852685

2686-
if (wrapperSetterIsUsable)
2687-
info = StorageImplInfo(ReadImplKind::Get, WriteImplKind::Set,
2688-
ReadWriteImplKind::Modify);
2689-
else
2686+
bool hasObservers = var->getParsedAccessor(AccessorKind::DidSet) ||
2687+
var->getParsedAccessor(AccessorKind::WillSet);
2688+
2689+
if (wrapperSetterIsUsable) {
2690+
if (hasObservers) {
2691+
info = StorageImplInfo::getMutableComputed();
2692+
} else {
2693+
info = StorageImplInfo(ReadImplKind::Get, WriteImplKind::Set,
2694+
ReadWriteImplKind::Modify);
2695+
}
2696+
} else {
26902697
info = StorageImplInfo::getImmutableComputed();
2698+
}
26912699
}
26922700

26932701
static void finishNSManagedImplInfo(VarDecl *var,

0 commit comments

Comments
 (0)