Skip to content

Commit

Permalink
Merge pull request #74100 from slavapestov/fix-rdar129024926
Browse files Browse the repository at this point in the history
Sema: Fix request cycle with isolation inference
  • Loading branch information
slavapestov authored Jun 3, 2024
2 parents 48237b8 + 3196164 commit 8493312
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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
}

0 comments on commit 8493312

Please sign in to comment.