Skip to content

Sema: Fix request cycle with isolation inference #74100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/Sema/TypeCheckConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions test/Concurrency/sendable_checking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}