Skip to content

Commit 1cc25b9

Browse files
committed
Support unavailable and obsoleted attributes on extensions
Members of an extension inherit the availability of the extension. This was previously supported for introduced and deprecated, but not unavailable and obsoleted. rdar://problem/50949936
1 parent 4dcb49d commit 1cc25b9

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/AST/Attr.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,14 @@ AvailableVersionComparison AvailableAttr::getVersionAvailability(
10481048

10491049
const AvailableAttr *AvailableAttr::isUnavailable(const Decl *D) {
10501050
ASTContext &ctx = D->getASTContext();
1051-
return D->getAttrs().getUnavailable(ctx);
1051+
if (auto attr = D->getAttrs().getUnavailable(ctx))
1052+
return attr;
1053+
1054+
// If D is an extension member, check if the extension is unavailable.
1055+
if (auto ext = dyn_cast<ExtensionDecl>(D->getDeclContext()))
1056+
return AvailableAttr::isUnavailable(ext);
1057+
1058+
return nullptr;
10521059
}
10531060

10541061
SpecializeAttr::SpecializeAttr(SourceLoc atLoc, SourceRange range,

0 commit comments

Comments
 (0)