Skip to content

Commit 4c605a2

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 5ce1668 commit 4c605a2

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
@@ -7279,7 +7279,10 @@ void AttributeChecker::visitUnsafeInheritExecutorAttr(
72797279
auto fn = cast<FuncDecl>(D);
72807280
if (!fn->isAsyncContext()) {
72817281
diagnose(attr->getLocation(), diag::inherits_executor_without_async);
7282-
} else {
7282+
} else if (fn->getBaseName().isSpecial() ||
7283+
!fn->getParentModule()->getName().str().equals("_Concurrency") ||
7284+
!fn->getBaseIdentifier().str()
7285+
.startswith("_unsafeInheritExecutor_")) {
72837286
bool inConcurrencyModule = D->getDeclContext()->getParentModule()->getName()
72847287
.str().equals("_Concurrency");
72857288
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)