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

[SR-12350] Projected PropertyWrappers don't trigger didSet when their wrappedValue is mutated #54784

Closed
swift-ci opened this issue Mar 12, 2020 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself property wrappers Feature: property wrappers type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-12350
Radar rdar://problem/60832797
Original Reporter benpious (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Version 11.2.1.

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, PropertyWrappers, TypeChecker
Assignee None
Priority Medium

md5: d596f1ad1d1b43797a7c9312e67b0d4a

duplicates:

  • SR-12089 Swift 5.2 snapshot: didSet not called

is duplicated by:

  • SR-12477 Assignments to projected PropertyWrappers with overlapping mutations of the var itself are not considered a memory exclusivity violation

Issue Description:

If I call myInstance.$myWrappedVar.wrappedValue = someValue, I would expect the didSet observer declared in myInstance to be called.

This is a very superficial case, so I've also attached an example of where you'd want to have something like myInstance.$myWrappedVar.doSomething(), which mutates wrappedValue internally cause the didSet Observer to be called.

The language reference doesn't explicitly say that the didSet observer isn't called, so I'm calling this a bug and not a feature request, though perhaps it's a bug in the documentation and not the implementation.

@beccadax
Copy link
Contributor

@swift-ci create

@theblixguy
Copy link
Collaborator

This is the same as SR-12089, it's a known problem that property observers on wrapped properties do not fire in scenarios where the access goes through _modify. I have a https://github.com/apple/swift/pull/29931 up to fix it but run into some other problems which I plan to look into shortly.

@swift-ci
Copy link
Collaborator Author

Comment by Peter Schorn (JIRA)

Why is this marked as resolved? This issue still occurs for me. Or is this the intended behavior?

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself property wrappers Feature: property wrappers type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants