Skip to content

[Concurrency] ReferenceWritableKeyPath of main-actor bound property cannot be created inside a non-isolated context #77774

Open
@xavierjurado

Description

@xavierjurado

Description

While using a ReferenceWritableKeyPath should be limited to the actor where the property it's referencing is bound, creating such key path should be allowed on any context.

Reproduction

  nonisolated func testKeyPath() {
    let keyPath: ReferenceWritableKeyPath<UIView, _> = \.backgroundColor // Error: Cannot form key path to main actor-isolated property 'backgroundColor'
  }

Expected behavior

ReferenceWritableKeyPath can be created from any context, but the compiler prevents applying such keypath outside of the context where the property is bound (ie: outside of @MainActor in the example above).

Environment

swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)

Additional information

cc @hborla

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.concurrencyFeature: umbrella label for concurrency language featuresswift evolution proposal neededFlag → feature: A feature that warrants a Swift evolution proposal

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions