Skip to content

Commit 38e7c1d

Browse files
committed
Suppress warnings about @_unsafeInheritExecutor on _unsafeInheritExecutor_ functions
When inside the concurrency library, suppress the diagnostics about use of the (deprecated) `@_unsafeInheritExecutor` for functions whose names start with the "_unsafeInheritExecutor_" prefix that's used for compatibility. This focuses the diagnostic on those places in the concurrency library that might still need to introduce this hack.
1 parent 3c48cdd commit 38e7c1d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7213,7 +7213,10 @@ void AttributeChecker::visitUnsafeInheritExecutorAttr(
72137213
auto fn = cast<FuncDecl>(D);
72147214
if (!fn->isAsyncContext()) {
72157215
diagnose(attr->getLocation(), diag::inherits_executor_without_async);
7216-
} else {
7216+
} else if (fn->getBaseName().isSpecial() ||
7217+
!fn->getParentModule()->getName().str().equals("_Concurrency") ||
7218+
!fn->getBaseIdentifier().str()
7219+
.startswith("_unsafeInheritExecutor_")) {
72177220
bool inConcurrencyModule = D->getDeclContext()->getParentModule()->getName()
72187221
.str().equals("_Concurrency");
72197222
auto diag = fn->diagnose(diag::unsafe_inherits_executor_deprecated);

test/Concurrency/unsafe_inherit_executor.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,7 @@ func unsafeCallerAvoidsNewLoop(clock: some Clock) async throws {
172172
throw MyError.fail
173173
}
174174
}
175+
176+
@_unsafeInheritExecutor
177+
func _unsafeInheritExecutor_hacky() async { }
178+
// expected-warning@-1{{@_unsafeInheritExecutor attribute is deprecated; consider an 'isolated' parameter defaulted to '#isolation' instead}}

0 commit comments

Comments
 (0)