Merge pull request #74100 from slavapestov/fix-rdar129024926

Sema: Fix request cycle with isolation inference
This commit is contained in:
Slava Pestov
2024-06-03 17:51:04 -04:00
committed by GitHub
2 changed files with 15 additions and 0 deletions

View File

@@ -4456,6 +4456,11 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
/// Infer isolation from witnessed protocol requirements.
static std::optional<ActorIsolation>
getIsolationFromWitnessedRequirements(ValueDecl *value) {
// Associated types cannot have isolation, so there's no such inference for
// type witnesses.
if (isa<TypeDecl>(value))
return std::nullopt;
auto dc = value->getDeclContext();
auto idc = dyn_cast_or_null<IterableDeclContext>(dc->getAsDecl());
if (!idc)

View File

@@ -481,3 +481,13 @@ func checkOpaqueType() -> some Sendable {
UnavailableSendable()
// expected-warning@-1 {{conformance of 'UnavailableSendable' to 'Sendable' is unavailable; this is an error in the Swift 6 language mode}}
}
// rdar://129024926
@available(SwiftStdlib 5.1, *)
@MainActor class MainActorSuper<T: Sendable> {}
@available(SwiftStdlib 5.1, *)
class MainActorSub: MainActorSuper<MainActorSub.Nested> {
struct Nested {} // no cycle
}