Skip to content

[Sema] Allow Sendable conformance for structs with global-actor-isolated stored properties#87580

Open
aydinomer00 wants to merge 1 commit intoswiftlang:mainfrom
aydinomer00:fix/sendable-struct-global-actor-isolated-property
Open

[Sema] Allow Sendable conformance for structs with global-actor-isolated stored properties#87580
aydinomer00 wants to merge 1 commit intoswiftlang:mainfrom
aydinomer00:fix/sendable-struct-global-actor-isolated-property

Conversation

@aydinomer00
Copy link

Actor-isolated stored properties can only be accessed from within their isolation domain, so they are already safe regardless of whether the enclosing type is a class or a struct. However, checkSendableInstanceStorage() only skipped the Sendable member check for actor-isolated properties when the enclosing type was a class. This meant a final class with @MainActor let of non-Sendable type was accepted as Sendable, but an identical struct was rejected.

This change lifts the actor-isolation guard out of the isa<ClassDecl> block so it applies uniformly to all nominal types.

Changes:

  • lib/Sema/TypeCheckConcurrency.cpp — moved the isolation check to apply to structs/enums too
  • test/Concurrency/concurrent_value_checking.swift — added struct regression tests (S13, S14)

Resolves #87543

…d properties

Actor-isolated properties in classes already skip the Sendable member
type check, but structs did not have the same exemption. This caused an
inconsistency where a final class with a @mainactor let of non-Sendable
type was accepted as Sendable, but a struct with the same property was
rejected.

Move the actor-isolation skip check outside the isa<ClassDecl> guard so
it applies uniformly to all nominal types (classes, structs, enums).

Resolves swiftlang#87543
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Difference in checked Sendable eligibility between class and struct with global-isolated property

1 participant