Skip to content

Commit 4fa8c55

Browse files
committed
Sema: Fix diagnostics for @available(noasync, swift).
1 parent 76243a2 commit 4fa8c55

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8271,7 +8271,6 @@ SemanticAvailableAttrRequest::evaluate(swift::Evaluator &evaluator,
82718271
auto &diags = decl->getASTContext().Diags;
82728272
auto attrLoc = attr->getLocation();
82738273
auto attrName = attr->getAttrName();
8274-
auto attrKind = attr->getKind();
82758274
auto domainLoc = attr->getDomainLoc();
82768275
auto introducedVersion = attr->getRawIntroduced();
82778276
auto deprecatedVersion = attr->getRawDeprecated();
@@ -8305,7 +8304,7 @@ SemanticAvailableAttrRequest::evaluate(swift::Evaluator &evaluator,
83058304
auto domainName = domain->getNameForAttributePrinting();
83068305

83078306
if (domain->isSwiftLanguage() || domain->isPackageDescription()) {
8308-
switch (attrKind) {
8307+
switch (attr->getKind()) {
83098308
case AvailableAttr::Kind::Deprecated:
83108309
diags.diagnose(attrLoc,
83118310
diag::attr_availability_expected_deprecated_version,
@@ -8320,7 +8319,8 @@ SemanticAvailableAttrRequest::evaluate(swift::Evaluator &evaluator,
83208319
case AvailableAttr::Kind::NoAsync:
83218320
diags.diagnose(attrLoc, diag::attr_availability_cannot_be_used_for_domain,
83228321
"noasync", attrName, domainName);
8323-
break;
8322+
return std::nullopt;
8323+
83248324
case AvailableAttr::Kind::Default:
83258325
break;
83268326
}

test/attr/attr_availability_noasync.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@ func asyncReplacement() async -> Int { }
1818
@available(*, noasync, renamed: "IOActor.readString()")
1919
func readStringFromIO() -> String {}
2020

21-
// expected-warning@+2 {{'noasync' cannot be used in 'available' attribute for platform 'swift'}}
22-
// expected-warning@+1 {{expected 'introduced', 'deprecated', or 'obsoleted' in 'available' attribute for platform 'swift'}}
21+
// expected-warning@+1 {{'noasync' cannot be used in 'available' attribute for platform 'swift'}}
2322
@available(swift, noasync)
2423
func swiftNoAsync() { }
2524

26-
// expected-warning@+2 {{'noasync' cannot be used in 'available' attribute for platform '_PackageDescription'}}
27-
// expected-warning@+1 {{expected 'introduced', 'deprecated', or 'obsoleted' in 'available' attribute for platform '_PackageDescription'}}
25+
// expected-warning@+1 {{'noasync' cannot be used in 'available' attribute for platform '_PackageDescription'}}
2826
@available(_PackageDescription, noasync)
2927
func packageDescriptionNoAsync() { }
3028

0 commit comments

Comments
 (0)