Skip to content

Commit f087a68

Browse files
committed
[Typechecker] Wrapped properties with observers should not have ReadWriteImplKind::Modify
1 parent a543bfb commit f087a68

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
@@ -2581,11 +2581,19 @@ static void finishPropertyWrapperImplInfo(VarDecl *var,
25812581
}
25822582
}
25832583

2584-
if (wrapperSetterIsUsable)
2585-
info = StorageImplInfo(ReadImplKind::Get, WriteImplKind::Set,
2586-
ReadWriteImplKind::Modify);
2587-
else
2584+
bool hasObservers = var->getParsedAccessor(AccessorKind::DidSet) ||
2585+
var->getParsedAccessor(AccessorKind::WillSet);
2586+
2587+
if (wrapperSetterIsUsable) {
2588+
if (hasObservers) {
2589+
info = StorageImplInfo::getMutableComputed();
2590+
} else {
2591+
info = StorageImplInfo(ReadImplKind::Get, WriteImplKind::Set,
2592+
ReadWriteImplKind::Modify);
2593+
}
2594+
} else {
25882595
info = StorageImplInfo::getImmutableComputed();
2596+
}
25892597
}
25902598

25912599
static void finishNSManagedImplInfo(VarDecl *var,

0 commit comments

Comments
 (0)