Representational changes towards get-and-mutableAddress

properties.

The main design change here is that, rather than having
purportedly orthogonal storage kinds and has-addressor
bits, I've merged them into an exhaustive enum of the
possibilities.  I've also split the observing storage kind
into stored-observing and inherited-observing cases, which
is possible to do in the parser because the latter are
always marked 'override' and the former aren't.  This
should lead to much better consideration for inheriting
observers, which were otherwise very easy to forget about.
It also gives us much better recovery when override checking
fails before we can identify the overridden declaration;
previously, we would end up spuriously considering the
override to be a stored property despite the user's
clearly expressed intent.

Swift SVN r22381
This commit is contained in:
John McCall
2014-09-30 08:39:38 +00:00
parent 27363b24fb
commit 8c303ef7a6
18 changed files with 732 additions and 302 deletions

View File

@@ -2981,11 +2981,23 @@ ConstraintSystem::simplifyMemberConstraint(const Constraint &constraint) {
// as the getter is nonmutating.
if (auto storage = dyn_cast<AbstractStorageDecl>(result)) {
auto isGetterMutating = [](AbstractStorageDecl *storage) {
if (storage->hasAccessorFunctions())
switch (storage->getStorageKind()) {
case AbstractStorageDecl::Stored:
return false;
case AbstractStorageDecl::StoredWithObservers:
case AbstractStorageDecl::StoredWithTrivialAccessors:
case AbstractStorageDecl::InheritedWithObservers:
case AbstractStorageDecl::ComputedWithMutableAddress:
case AbstractStorageDecl::Computed:
case AbstractStorageDecl::AddressedWithTrivialAccessors:
case AbstractStorageDecl::AddressedWithObservers:
return storage->getGetter()->isMutating();
if (storage->hasAddressors())
case AbstractStorageDecl::Addressed:
return storage->getAddressor()->isMutating();
return false;
}
llvm_unreachable("bad storage kind");
};
if (isGetterMutating(storage)) {