@@ -197,7 +197,7 @@ void AvailabilityInference::applyInferredAvailableAttrs(
197
197
198
198
// Walk up the enclosing declaration hierarchy to make sure we aren't
199
199
// missing any inherited attributes.
200
- D = AvailabilityInference::parentDeclForInferredAvailability (D );
200
+ D = D-> parentDeclForAvailability ( );
201
201
} while (D);
202
202
}
203
203
@@ -213,32 +213,31 @@ void AvailabilityInference::applyInferredAvailableAttrs(
213
213
214
214
// / Returns the decl that should be considered the parent decl of the given decl
215
215
// / 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 ))
219
218
return AD->getStorage ();
220
219
221
- if (auto *ED = dyn_cast<ExtensionDecl>(D )) {
220
+ if (auto *ED = dyn_cast<ExtensionDecl>(this )) {
222
221
if (auto *NTD = ED->getExtendedNominal ())
223
222
return NTD;
224
223
}
225
224
226
- if (auto *PBD = dyn_cast<PatternBindingDecl>(D )) {
225
+ if (auto *PBD = dyn_cast<PatternBindingDecl>(this )) {
227
226
if (PBD->getNumPatternEntries () < 1 )
228
227
return nullptr ;
229
228
230
229
return PBD->getAnchoringVarDecl (0 );
231
230
}
232
231
233
- if (auto *OTD = dyn_cast<OpaqueTypeDecl>(D ))
232
+ if (auto *OTD = dyn_cast<OpaqueTypeDecl>(this ))
234
233
return OTD->getNamingDecl ();
235
234
236
235
// Clang decls may be inaccurately parented rdar://53956555
237
- if (D-> hasClangNode ())
236
+ if (hasClangNode ())
238
237
return nullptr ;
239
238
240
239
// Availability is inherited from the enclosing context.
241
- return D-> getDeclContext ()->getInnermostDeclarationDeclContext ();
240
+ return getDeclContext ()->getInnermostDeclarationDeclContext ();
242
241
}
243
242
244
243
// / Returns true if the introduced version in \p newAttr should be used instead
@@ -408,7 +407,10 @@ AvailabilityInference::annotatedAvailableRange(const Decl *D) {
408
407
}
409
408
410
409
bool Decl::isAvailableAsSPI () const {
411
- return AvailabilityInference::isAvailableAsSPI (this );
410
+ if (auto attr = getAvailableAttrForPlatformIntroduction ())
411
+ return attr->isSPI ();
412
+
413
+ return false ;
412
414
}
413
415
414
416
SemanticAvailableAttributes
@@ -696,10 +698,8 @@ DeclRuntimeAvailability
696
698
DeclRuntimeAvailabilityRequest::evaluate (Evaluator &evaluator,
697
699
const Decl *decl) const {
698
700
auto inherited = DeclRuntimeAvailability::PotentiallyAvailable;
699
- if (auto *parent =
700
- AvailabilityInference::parentDeclForInferredAvailability (decl)) {
701
+ if (auto *parent = decl->parentDeclForAvailability ())
701
702
inherited = getDeclRuntimeAvailability (parent);
702
- }
703
703
704
704
// If the inherited runtime availability is already maximally unavailable
705
705
// then skip computing unavailability for this declaration.
@@ -785,8 +785,7 @@ Decl::getAvailableAttrForPlatformIntroduction(bool checkExtension) const {
785
785
if (!checkExtension)
786
786
return std::nullopt;
787
787
788
- if (auto parent =
789
- AvailabilityInference::parentDeclForInferredAvailability (this )) {
788
+ if (auto parent = parentDeclForAvailability ()) {
790
789
if (auto *ED = dyn_cast<ExtensionDecl>(parent)) {
791
790
if (auto attr = getDeclAvailableAttrForPlatformIntroduction (ED))
792
791
return attr;
@@ -804,13 +803,6 @@ AvailabilityRange AvailabilityInference::availableRange(const Decl *D) {
804
803
return AvailabilityRange::alwaysAvailable ();
805
804
}
806
805
807
- bool AvailabilityInference::isAvailableAsSPI (const Decl *D) {
808
- if (auto attr = D->getAvailableAttrForPlatformIntroduction ())
809
- return attr->isSPI ();
810
-
811
- return false ;
812
- }
813
-
814
806
std::optional<SemanticAvailableAttr>
815
807
SemanticAvailableAttrRequest::evaluate (swift::Evaluator &evaluator,
816
808
const AvailableAttr *attr,
0 commit comments