Skip to content

Commit 0de339d

Browse files
committed
AST: Introduce a SemanticAvailableAttr::isNoAsync() convenience.
1 parent ff83bf3 commit 0de339d

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

include/swift/AST/Attr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3197,6 +3197,9 @@ class SemanticAvailableAttr final {
31973197
/// `PlatformKind::none` if the attribute is not platform specific.
31983198
PlatformKind getPlatformKind() const { return getDomain().getPlatformKind(); }
31993199

3200+
/// Whether this is a `noasync` attribute.
3201+
bool isNoAsync() const { return attr->isNoAsync(); }
3202+
32003203
/// Whether this attribute has an introduced, deprecated, or obsoleted
32013204
/// version.
32023205
bool isVersionSpecific() const {

lib/AST/Availability.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,8 +588,7 @@ const AvailableAttr *Decl::getNoAsyncAttr() const {
588588
getSemanticAvailableAttrs(/*includingInactive=*/false)) {
589589
auto attr = semanticAttr.getParsedAttr();
590590

591-
if (attr->getPlatformAgnosticAvailability() !=
592-
PlatformAgnosticAvailabilityKind::NoAsync)
591+
if (!semanticAttr.isNoAsync())
593592
continue;
594593

595594
if (!bestAttr) {

lib/AST/Decl.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9278,16 +9278,14 @@ AbstractFunctionDecl *AbstractFunctionDecl::getAsyncAlternative() const {
92789278
// `getAttrs` is in reverse source order, so the last attribute is the
92799279
// first in source.
92809280
AbstractFunctionDecl *alternative = nullptr;
9281-
for (auto semanticAttr : getSemanticAvailableAttrs()) {
9282-
auto attr = semanticAttr.getParsedAttr();
9283-
9284-
if (attr->isNoAsync())
9281+
for (auto attr : getSemanticAvailableAttrs()) {
9282+
if (attr.isNoAsync())
92859283
continue;
92869284

9287-
if (attr->getPlatform() != PlatformKind::none && alternative != nullptr)
9285+
if (attr.isPlatformSpecific() && alternative != nullptr)
92889286
continue;
92899287

9290-
if (auto *renamedDecl = getRenamedDecl(attr)) {
9288+
if (auto *renamedDecl = getRenamedDecl(attr.getParsedAttr())) {
92919289
if (auto *afd = dyn_cast<AbstractFunctionDecl>(renamedDecl)) {
92929290
if (afd->hasAsync())
92939291
alternative = afd;

0 commit comments

Comments
 (0)