-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add implementation of SE-0185 to CHANGELOG #12447
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
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.
I have a couple of minor suggested edits, other than that this is great!
CHANGELOG.md
Outdated
|
||
* [SE-0185][] | ||
|
||
Structs and enums now automatically receive synthesized implementations of `Equatable` and/or `Hashable` if all of their stored members conform to those protocols. You must explicitly declare that the type conforms to `Equatable`/`Hashable` (not in an extension), but the compiler will provide the implementation of `==`/`hashValue` for you if you do not write one yourself. |
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.
Nitpick: until the second sentence this suggests that the conformance is added automatically. Maybe a better way to phrase it would be "Structs and enums declared a conformance to Equatable
/Hashable
now get an automatically synthesized implementation of ==
/hashValue
. For structs, all stored properties must be Equatable
/Hashable
. For enums, all enum cases with associated values must be Equatable
/Hashable
".
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.
Done.
Swift 4.1 | ||
--------- | ||
|
||
* [SE-0185][] |
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.
I think you need to add the link to the actual proposal elsewhere in the file for this to work
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.
Much to my surprise, it was already there! (Last line of https://raw.githubusercontent.com/apple/swift/master/CHANGELOG.md.)
CHANGELOG.md
Outdated
```swift | ||
public enum Token: Hashable { | ||
case comma | ||
case identifier(String) |
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.
You can also have a case with a tuple type, right? Might be worth adding an example of that too.
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.
Not yet, unfortunately. The proposal and implementation only covered types where all stored members strictly conform to the protocol. There's no special handling for tuples yet (I'm happy to work on it as a follow-up).
That also means that the somewhat obvious case of Optional
isn't handled yet, either. My hope was that conditional conformances would be a reality in time for this feature to pick it up, but perhaps that should be added as a special case as well in the meantime?
@tkremenek What heading should we use for new features that are not in any announced release? |
d812875
to
6260113
Compare
@slavapestov use Swift 4.1 |
Since this is the first post-4.0 item in the change log, I wasn't sure if it should be considered Swift 4.1 or something else—let me know if that should change.