@@ -4946,21 +4946,19 @@ ProtocolDecl::findProtocolSelfReferences(const ValueDecl *value,
4946
4946
return result;
4947
4947
}
4948
4948
4949
- return ::findProtocolSelfReferences(this , type,
4950
- skipAssocTypes);
4951
- } else if (auto subscript = dyn_cast<SubscriptDecl>(value)) {
4952
- // Check the requirements of a generic subscript.
4953
- if (subscript->isGeneric ()) {
4954
- if (auto result =
4955
- ::findProtocolSelfReferences (this ,
4956
- subscript->getGenericSignature ()))
4957
- return result;
4958
- }
4959
-
4960
4949
return ::findProtocolSelfReferences(this , type,
4961
4950
skipAssocTypes);
4962
4951
} else {
4963
- assert (isa<VarDecl>(value));
4952
+ assert (isa<AbstractStorageDecl>(value));
4953
+
4954
+ if (auto *const subscript = dyn_cast<SubscriptDecl>(value)) {
4955
+ // Check the requirements of a generic subscript.
4956
+ if (subscript->isGeneric ()) {
4957
+ if (auto result = ::findProtocolSelfReferences (
4958
+ this , subscript->getGenericSignature ()))
4959
+ return result;
4960
+ }
4961
+ }
4964
4962
4965
4963
return ::findProtocolSelfReferences (this , type,
4966
4964
skipAssocTypes);
@@ -4978,6 +4976,12 @@ bool ProtocolDecl::isAvailableInExistential(const ValueDecl *decl) const {
4978
4976
if (selfKind.parameter || selfKind.other )
4979
4977
return false ;
4980
4978
4979
+ // FIXME: Appropriately diagnose assignments instead.
4980
+ if (auto *const storageDecl = dyn_cast<AbstractStorageDecl>(decl)) {
4981
+ if (selfKind.result && storageDecl->supportsMutation ())
4982
+ return false ;
4983
+ }
4984
+
4981
4985
return true ;
4982
4986
}
4983
4987
0 commit comments