@@ -2220,7 +2220,7 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *attr) {
2220
2220
}
2221
2221
}
2222
2222
2223
- std::optional<Diag<> > MaybeNotAllowed =
2223
+ std::optional<Diagnostic > MaybeNotAllowed =
2224
2224
TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable (D);
2225
2225
if (MaybeNotAllowed.has_value ()) {
2226
2226
AvailabilityContext DeploymentRange
@@ -4924,13 +4924,19 @@ Type TypeChecker::checkReferenceOwnershipAttr(VarDecl *var, Type type,
4924
4924
return ReferenceStorageType::get (type, ownershipKind, var->getASTContext ());
4925
4925
}
4926
4926
4927
- std::optional<Diag<> >
4927
+ std::optional<Diagnostic >
4928
4928
TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable (const Decl *D) {
4929
4929
auto *DC = D->getDeclContext ();
4930
4930
4931
4931
// A destructor is always called if declared.
4932
4932
if (auto *DD = dyn_cast<DestructorDecl>(D))
4933
- return diag::availability_deinit_no_potential;
4933
+ return Diagnostic (diag::availability_decl_no_potential, D);
4934
+
4935
+ // Observing accessors are always called implicitly.
4936
+ if (auto *AD = dyn_cast<AccessorDecl>(D)) {
4937
+ if (AD->isObservingAccessor ())
4938
+ return Diagnostic (diag::availability_decl_no_potential, D);
4939
+ }
4934
4940
4935
4941
if (auto *VD = dyn_cast<VarDecl>(D)) {
4936
4942
if (!VD->hasStorageOrWrapsStorage ())
@@ -4964,7 +4970,7 @@ TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable(const Decl *D) {
4964
4970
return std::nullopt ;
4965
4971
}
4966
4972
4967
- std::optional<Diag<> >
4973
+ std::optional<Diagnostic >
4968
4974
TypeChecker::diagnosticIfDeclCannotBeUnavailable (const Decl *D) {
4969
4975
auto parentIsUnavailable = [](const Decl *D) -> bool {
4970
4976
if (auto *parent =
@@ -4979,7 +4985,18 @@ TypeChecker::diagnosticIfDeclCannotBeUnavailable(const Decl *D) {
4979
4985
if (parentIsUnavailable (D))
4980
4986
return std::nullopt ;
4981
4987
4982
- return diag::availability_deinit_no_unavailable;
4988
+ return Diagnostic (diag::availability_decl_no_unavailable, D);
4989
+ }
4990
+
4991
+ // The conformance checker does not know what to do with unavailable
4992
+ // associated types.
4993
+ if (auto *AT = dyn_cast<AssociatedTypeDecl>(D))
4994
+ return Diagnostic (diag::availability_decl_no_unavailable, D);
4995
+
4996
+ // Observing accessors are always called implicitly.
4997
+ if (auto *AD = dyn_cast<AccessorDecl>(D)) {
4998
+ if (AD->isObservingAccessor ())
4999
+ return Diagnostic (diag::availability_decl_no_unavailable, D);
4983
5000
}
4984
5001
4985
5002
if (auto *VD = dyn_cast<VarDecl>(D)) {
0 commit comments