@@ -197,7 +197,7 @@ void AvailabilityInference::applyInferredAvailableAttrs(
197197
198198 // Walk up the enclosing declaration hierarchy to make sure we aren't
199199 // missing any inherited attributes.
200- D = AvailabilityInference::parentDeclForInferredAvailability (D );
200+ D = D-> parentDeclForAvailability ( );
201201 } while (D);
202202 }
203203
@@ -213,32 +213,31 @@ void AvailabilityInference::applyInferredAvailableAttrs(
213213
214214// / Returns the decl that should be considered the parent decl of the given decl
215215// / when looking for inherited availability annotations.
216- const Decl *
217- AvailabilityInference::parentDeclForInferredAvailability (const Decl *D) {
218- if (auto *AD = dyn_cast<AccessorDecl>(D))
216+ const Decl *Decl::parentDeclForAvailability () const {
217+ if (auto *AD = dyn_cast<AccessorDecl>(this ))
219218 return AD->getStorage ();
220219
221- if (auto *ED = dyn_cast<ExtensionDecl>(D )) {
220+ if (auto *ED = dyn_cast<ExtensionDecl>(this )) {
222221 if (auto *NTD = ED->getExtendedNominal ())
223222 return NTD;
224223 }
225224
226- if (auto *PBD = dyn_cast<PatternBindingDecl>(D )) {
225+ if (auto *PBD = dyn_cast<PatternBindingDecl>(this )) {
227226 if (PBD->getNumPatternEntries () < 1 )
228227 return nullptr ;
229228
230229 return PBD->getAnchoringVarDecl (0 );
231230 }
232231
233- if (auto *OTD = dyn_cast<OpaqueTypeDecl>(D ))
232+ if (auto *OTD = dyn_cast<OpaqueTypeDecl>(this ))
234233 return OTD->getNamingDecl ();
235234
236235 // Clang decls may be inaccurately parented rdar://53956555
237- if (D-> hasClangNode ())
236+ if (hasClangNode ())
238237 return nullptr ;
239238
240239 // Availability is inherited from the enclosing context.
241- return D-> getDeclContext ()->getInnermostDeclarationDeclContext ();
240+ return getDeclContext ()->getInnermostDeclarationDeclContext ();
242241}
243242
244243// / Returns true if the introduced version in \p newAttr should be used instead
@@ -699,10 +698,8 @@ DeclRuntimeAvailability
699698DeclRuntimeAvailabilityRequest::evaluate (Evaluator &evaluator,
700699 const Decl *decl) const {
701700 auto inherited = DeclRuntimeAvailability::PotentiallyAvailable;
702- if (auto *parent =
703- AvailabilityInference::parentDeclForInferredAvailability (decl)) {
701+ if (auto *parent = decl->parentDeclForAvailability ())
704702 inherited = getDeclRuntimeAvailability (parent);
705- }
706703
707704 // If the inherited runtime availability is already maximally unavailable
708705 // then skip computing unavailability for this declaration.
@@ -788,8 +785,7 @@ Decl::getAvailableAttrForPlatformIntroduction(bool checkExtension) const {
788785 if (!checkExtension)
789786 return std::nullopt ;
790787
791- if (auto parent =
792- AvailabilityInference::parentDeclForInferredAvailability (this )) {
788+ if (auto parent = parentDeclForAvailability ()) {
793789 if (auto *ED = dyn_cast<ExtensionDecl>(parent)) {
794790 if (auto attr = getDeclAvailableAttrForPlatformIntroduction (ED))
795791 return attr;
0 commit comments