@@ -2220,7 +2220,7 @@ void AttributeChecker::visitAvailableAttr(AvailableAttr *attr) {
22202220 }
22212221 }
22222222
2223- std::optional<Diag<> > MaybeNotAllowed =
2223+ std::optional<Diagnostic > MaybeNotAllowed =
22242224 TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable (D);
22252225 if (MaybeNotAllowed.has_value ()) {
22262226 AvailabilityContext DeploymentRange
@@ -4924,13 +4924,19 @@ Type TypeChecker::checkReferenceOwnershipAttr(VarDecl *var, Type type,
49244924 return ReferenceStorageType::get (type, ownershipKind, var->getASTContext ());
49254925}
49264926
4927- std::optional<Diag<> >
4927+ std::optional<Diagnostic >
49284928TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable (const Decl *D) {
49294929 auto *DC = D->getDeclContext ();
49304930
49314931 // A destructor is always called if declared.
49324932 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+ }
49344940
49354941 if (auto *VD = dyn_cast<VarDecl>(D)) {
49364942 if (!VD->hasStorageOrWrapsStorage ())
@@ -4964,7 +4970,7 @@ TypeChecker::diagnosticIfDeclCannotBePotentiallyUnavailable(const Decl *D) {
49644970 return std::nullopt ;
49654971}
49664972
4967- std::optional<Diag<> >
4973+ std::optional<Diagnostic >
49684974TypeChecker::diagnosticIfDeclCannotBeUnavailable (const Decl *D) {
49694975 auto parentIsUnavailable = [](const Decl *D) -> bool {
49704976 if (auto *parent =
@@ -4979,7 +4985,18 @@ TypeChecker::diagnosticIfDeclCannotBeUnavailable(const Decl *D) {
49794985 if (parentIsUnavailable (D))
49804986 return std::nullopt ;
49814987
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);
49835000 }
49845001
49855002 if (auto *VD = dyn_cast<VarDecl>(D)) {
0 commit comments