Skip to content

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

Merged
merged 1 commit into from
Oct 16, 2017

Conversation

allevato
Copy link
Member

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.

Copy link
Contributor

@slavapestov slavapestov left a 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.
Copy link
Contributor

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".

Copy link
Member Author

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][]
Copy link
Contributor

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

Copy link
Member Author

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)
Copy link
Contributor

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.

Copy link
Member Author

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?

@slavapestov
Copy link
Contributor

@tkremenek What heading should we use for new features that are not in any announced release?

@tkremenek
Copy link
Member

@slavapestov use Swift 4.1

@DougGregor DougGregor merged commit 62d7d79 into swiftlang:master Oct 16, 2017
@allevato allevato deleted the eq-hash-changelog branch October 16, 2017 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants