-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CSDiagnostics] Improving the fix-it for defining computed properties #23500
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
Conversation
cc @xedin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I only wonder though if problems like this are actually diagnosed via fixes or are they still failing through to CSDiag
?
@xedin For this specific case, it does go through the fix, but there are other cases where it doesn't go through the fix. I was running the tests and got a couple of failures, so I need to figure out a way to create a fix for all the cases, or leave the code in CSDiag so it can catch those other cases. |
@theblixguy I think it would be great to factor this logic into a separate diagnostic which could be used from both places if possible... |
@xedin I have extracted the fix-it code into a separate method in |
@swift-ci please smoke test |
Build failure on OSX looks unrelated to me.
|
@swift-ci please smoke test macOS platform |
Same error in SwiftPM. @aciidb0mb3r could you take a look? SPMLLBuild is crashing due to a force-unwrap here: https://github.com/apple/swift-package-manager/blob/master/Sources/SPMLLBuild/llbuild.swift#L186
|
Should be fixed now, try rerunning the CI |
I don't have the permission to run the CI, could you run the smoke test on macOS? It was the one that failed. |
@swift-ci please smoke test macOS platform |
1 similar comment
@swift-ci please smoke test macOS platform |
Thanks, all tests are passing now 🎉 |
@xedin Can I cherry pick this to the 5.1 branch? |
@theblixguy please do! |
This PR offers an improvement when the user is trying to define a computed property that is initialised with a closure. For example:
We currently emit an error diagnostic for the above, with a fix-it to add
()
:In case of extensions, we emit:
With this change, we will offer another fix-it to convert it into a computed property, by removing the
=
and if the property is immutable, then also changing thelet
to avar
.Resolves SR-9267.