Skip to content

Commit a8681de

Browse files
committed
Disable async availability checking for swift_deletedAsyncMethodError.
Prior versions of the _Concurrency library failed to provide appropriate availability annotations for `swift_deletedAsyncMethodError`, which makes them unusable with newer Swift compilers. Avoid this problem by not checking availability for this specific API. Fixes rdar://80967376.
1 parent 66f9db8 commit a8681de

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/Sema/TypeCheckDeclPrimary.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2568,6 +2568,13 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
25682568
return AFD->getResilienceExpansion() != ResilienceExpansion::Minimal;
25692569
}
25702570

2571+
/// FIXME: This is an egregious hack to turn off availability checking
2572+
/// for specific functions that were missing availability in older versions
2573+
/// of existing libraries that we must nonethess still support.
2574+
static bool hasHistoricallyWrongAvailability(FuncDecl *func) {
2575+
return func->getName().isCompoundName("swift_deletedAsyncMethodError", { });
2576+
}
2577+
25712578
void visitFuncDecl(FuncDecl *FD) {
25722579
// Force these requests in case they emit diagnostics.
25732580
(void) FD->getInterfaceType();
@@ -2612,7 +2619,8 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
26122619

26132620
checkImplementationOnlyOverride(FD);
26142621

2615-
if (FD->getAsyncLoc().isValid())
2622+
if (FD->getAsyncLoc().isValid() &&
2623+
!hasHistoricallyWrongAvailability(FD))
26162624
TypeChecker::checkConcurrencyAvailability(FD->getAsyncLoc(), FD);
26172625

26182626
if (requiresDefinition(FD) && !FD->hasBody()) {

test/Concurrency/concurrency_availability.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ func f() async { } // expected-error{{concurrency is only available in}}
77

88
actor A { } // expected-error{{concurrency is only available in}}
99
// expected-note@-1{{add @available}}
10+
11+
// Allow this without any availability for Historical Reasons.
12+
public func swift_deletedAsyncMethodError() async {
13+
}

0 commit comments

Comments
 (0)