@@ -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
@@ -699,10 +698,8 @@ DeclRuntimeAvailability
699
698
DeclRuntimeAvailabilityRequest::evaluate (Evaluator &evaluator,
700
699
const Decl *decl) const {
701
700
auto inherited = DeclRuntimeAvailability::PotentiallyAvailable;
702
- if (auto *parent =
703
- AvailabilityInference::parentDeclForInferredAvailability (decl)) {
701
+ if (auto *parent = decl->parentDeclForAvailability ())
704
702
inherited = getDeclRuntimeAvailability (parent);
705
- }
706
703
707
704
// If the inherited runtime availability is already maximally unavailable
708
705
// then skip computing unavailability for this declaration.
@@ -788,8 +785,7 @@ Decl::getAvailableAttrForPlatformIntroduction(bool checkExtension) const {
788
785
if (!checkExtension)
789
786
return std::nullopt ;
790
787
791
- if (auto parent =
792
- AvailabilityInference::parentDeclForInferredAvailability (this )) {
788
+ if (auto parent = parentDeclForAvailability ()) {
793
789
if (auto *ED = dyn_cast<ExtensionDecl>(parent)) {
794
790
if (auto attr = getDeclAvailableAttrForPlatformIntroduction (ED))
795
791
return attr;
0 commit comments