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-7293] Swift local refactoring: Customize Equatable Conformance #49841
Comments
This is no longer needed for structs and enums. Do you think it's worth having for classes, though? cc @allevato |
I suppose one possible use is to make it explicit so you can modify it. |
I agree—given that there's no annotation or other mechanism to exclude individual properties from ==, a local refactor would still be a valuable time-saver for users who want to generate it and then strip out a couple of the properties. |
Comment by Mohit Athwani (JIRA) If this is still needed and if no one is working on it, I'm willing to take this up 🙂 |
Comment by Mohit Athwani (JIRA) |
Sure, Mohit. I've just assigned it to you. |
Comment by Mohit Athwani (JIRA) @nkcsgexiThanks! I'm going to finish writing a blog post on how I attempted my previous PR and then got moving with this 🙂 |
Sounds great! We should rename this refactoring to "Customize Equatable Conformance" because using synthesized conformances is highly recommended. |
Comment by Mohit Athwani (JIRA) @nkcsgexi Finally got the time to start working on this. Updated all the repositories and tried to build with --debug --Xcode on Mojave and Xcode 10 and I got a Build Failed error. has something changed under the new os version? |
hmm, the build instruction should stay the same. What failure did you see? |
Comment by Mohit Athwani (JIRA) There's multiple clang errors. Got it fixed from this link: https://bugs.swift.org/browse/SR-7961 |
Resetting assignee on all Starter Bugs not modified since 2018. |
Comment by Andrii Tkachuk (JIRA) Hi! I would like to work on this improvement. cc @nkcsgexi |
Comment by Andrii Tkachuk (JIRA) Here is the PR: #29847 |
Comment by Andrii Tkachuk (JIRA) Included in Swift 5.3. |
Additional Detail from JIRA
md5: afc6ec2379362a2c31c09e7d29216645
relates to:
Issue Description:
A typical way of implementing equatable conformance is to check equal for all fields. A local refactoring can be implemented to help this pattern, e.g.
When a user right-clicks the declared name "Animal", an available refactoring "adding Equatable conformance" appears. After applying the refactoring, the above code snippet transforms to:
This code after transformation may not be the end outcome the user expected. However, they can always adjust if needed.
The text was updated successfully, but these errors were encountered: