Only emit the non-sendable metatype capture diagnostic under region-based isolation

We effectively suppress sendable diagnostics when region-based
isolation is disabled, and RBI is enabled whenever strict concurrency
checking is enabled. So, suppress this diagnostic when RBI is enabled.

Fixes rdar://152583759.
This commit is contained in:
Doug Gregor
2025-06-04 09:38:32 -07:00
parent 9f0dda5417
commit 332151aa69
2 changed files with 15 additions and 1 deletions

View File

@@ -3052,7 +3052,8 @@ namespace {
}
}
if (mayExecuteConcurrentlyWith(
if (ctx.LangOpts.hasFeature(Feature::RegionBasedIsolation) &&
mayExecuteConcurrentlyWith(
localFunc.getAsDeclContext(), getDeclContext(),
/*includeSending*/true)) {
auto innermostGenericDC = localFunc.getAsDeclContext();

View File

@@ -0,0 +1,13 @@
// RUN: %target-typecheck-verify-swift -swift-version 5
// REQUIRES: concurrency
protocol P {
static func doSomething()
}
func doSomethingStatic<T: P>(_: T.Type) {
Task { @concurrent in
T.doSomething()
}
}