Skip to content
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

[Sema] Propagate nonisolated attribute from wrapped property to the synthesized projectedValue property #60421

Conversation

theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Aug 5, 2022

Resolves #59380
Resolves #59494

We were not propagating the nonisolated attribute from the wrapped property to the synthesised projectedValue variable, thus triggering a main actor-isolated property '$<name>' can not be referenced from a non-isolated context error in some contexts when accessing the projectedValue.

@propertyWrapper 
struct Wrapper {
  var wrappedValue: Int { .zero }
  var projectedValue: Int { .max }
}

@MainActor
class Container {
  @Wrapper nonisolated var value

  deinit {
    _ = value // ok
    _ = $value // error
  }
}

@theblixguy theblixguy requested review from xedin and hborla August 5, 2022 21:29
@theblixguy theblixguy force-pushed the propagate-nonisolated-attr-synthesized-projectedValue branch from 7dcbc96 to 333f2fc Compare August 5, 2022 21:32
Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Could you please open a 5.7 PR for this as well?

@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

@theblixguy theblixguy merged commit 2aa47b8 into swiftlang:main Aug 9, 2022
@theblixguy theblixguy deleted the propagate-nonisolated-attr-synthesized-projectedValue branch August 9, 2022 00:40
theblixguy added a commit that referenced this pull request Aug 9, 2022
…to the synthesized projectedValue property (#60421)"

This reverts commit 2aa47b8.
theblixguy added a commit that referenced this pull request Aug 9, 2022
…to the synthesized projectedValue property (#60421)" (#60462)

This reverts commit 2aa47b8.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants