-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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-11298] Writable property declaration in a conditional-conforming protocol extension has incorrect mutability #53699
Comments
This is correct behavior; see SR-4541 for another example of it. |
I have a fix for this, but I am not sure if its a reasonable approach (although it works). cc @slavapestov does this look good to you? master...theblixguy:fix/SR-11298 |
@jckarter said on twitter that it seems like a bug: https://twitter.com/igormaka/status/1161223172278116352 |
Oh, whoops, I misread where the property was declared. Yes, this would be a bug and not the same as SR-4541. Thanks, @theblixguy! |
@belkadan No problem! Does my implementation look good to you? I can create a PR if it looks good. |
@slavapestov or maybe @xymus would have a better idea of whether this is the right place to do that work, but you can create the PR regardless. |
The code called from typeCheckDecl() only runs on declarations in the primary file, and they're visited in order. So if you use the storage from another file, or you have a forward reference in a primary file, the code you added won't run. Please take a look at incorporating it into SetterMutatingRequest::evaluate() instead. However I'm surprised this doesn't already work. There might be a bug elsewhere. In any case, feel free to put up a PR and we can discuss it in more detail there. Thanks for taking a look! |
Thanks! PR here: #26669 |
Fixed on master. Please verify using the next available master snapshot! |
Change got reverted - #26695 |
Yes, it’s currently being discussed on Swift forums because there’s some source breakage. I think we could un-revert it once it’s clear how to best handle this. |
Can you post a link to the discussion? |
Fixed on master: #27057 |
Reverting again, unfortunately (#27611 The fix doesn't just change the behavior of setters; it also changes the behavior of explicitly (I'm personally worried that this means we need |
Hmm, I guess we need to special case it for just setters then? |
I think you could keep your change for the default behavior but have the behavior with explicit |
Okay, I'll put up a new fix shortly. Could you provide an example where the behaviour shouldn't change? Just so I can add it to the tests. |
|
Fixed again by #27639 |
Comment by Joseph Twomey (JIRA) @swift-ci create |
Additional Detail from JIRA
md5: 24c2c75eac517f7dee964b09386971e2
duplicates:
Issue Description:
Attached snippet:
Because `wrappingProperty` is declared in a conditional conformance to `ClassA`, a class, `wrappingProperty` should be mutable, just like `property`.
In fact, if `Protocol` is declared as `class`, the code compiles without error.
Occurs in Swift 5.0 and 5.1.
Additional example, this time a read only getter:
The text was updated successfully, but these errors were encountered: