@@ -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
@@ -408,7 +407,10 @@ AvailabilityInference::annotatedAvailableRange(const Decl *D) {
408407}
409408
410409bool Decl::isAvailableAsSPI () const {
411- return AvailabilityInference::isAvailableAsSPI (this );
410+ if (auto attr = getAvailableAttrForPlatformIntroduction ())
411+ return attr->isSPI ();
412+
413+ return false ;
412414}
413415
414416SemanticAvailableAttributes
@@ -696,10 +698,8 @@ DeclRuntimeAvailability
696698DeclRuntimeAvailabilityRequest::evaluate (Evaluator &evaluator,
697699 const Decl *decl) const {
698700 auto inherited = DeclRuntimeAvailability::PotentiallyAvailable;
699- if (auto *parent =
700- AvailabilityInference::parentDeclForInferredAvailability (decl)) {
701+ if (auto *parent = decl->parentDeclForAvailability ())
701702 inherited = getDeclRuntimeAvailability (parent);
702- }
703703
704704 // If the inherited runtime availability is already maximally unavailable
705705 // then skip computing unavailability for this declaration.
@@ -785,8 +785,7 @@ Decl::getAvailableAttrForPlatformIntroduction(bool checkExtension) const {
785785 if (!checkExtension)
786786 return std::nullopt ;
787787
788- if (auto parent =
789- AvailabilityInference::parentDeclForInferredAvailability (this )) {
788+ if (auto parent = parentDeclForAvailability ()) {
790789 if (auto *ED = dyn_cast<ExtensionDecl>(parent)) {
791790 if (auto attr = getDeclAvailableAttrForPlatformIntroduction (ED))
792791 return attr;
@@ -804,13 +803,6 @@ AvailabilityRange AvailabilityInference::availableRange(const Decl *D) {
804803 return AvailabilityRange::alwaysAvailable ();
805804}
806805
807- bool AvailabilityInference::isAvailableAsSPI (const Decl *D) {
808- if (auto attr = D->getAvailableAttrForPlatformIntroduction ())
809- return attr->isSPI ();
810-
811- return false ;
812- }
813-
814806std::optional<SemanticAvailableAttr>
815807SemanticAvailableAttrRequest::evaluate (swift::Evaluator &evaluator,
816808 const AvailableAttr *attr,
0 commit comments