Skip to content

Make Trivia and TriviaPiece Equatable #89

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
Feb 19, 2019

Conversation

hartbit
Copy link
Contributor

@hartbit hartbit commented Feb 16, 2019

While writing a SyntaxRewriter, I need to check that some trivia was 'correct' or not before attempting to fix it, and was surprised that I couldn't compare Trivia easily. I've now added Hashable conformance to both Trivia and TriviaPiece.

@hartbit hartbit force-pushed the trivia-equatable-hashable branch from 5cc8bc5 to 339b018 Compare February 16, 2019 15:21
Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think being hashable is the right thing to do for trivia and trivia pieces. Could you downgrade it to equatable and implement custom == check?

@hartbit
Copy link
Contributor Author

hartbit commented Feb 18, 2019

I can downgrade it to Equatable, but why do you want custom == checks instead of relying on the compiler synthesized one?

@nkcsgexi
Copy link
Contributor

You’re right. Thinking more about this, the synthesized conformance should work just fine here.

@hartbit hartbit force-pushed the trivia-equatable-hashable branch from 339b018 to c3ba26c Compare February 18, 2019 07:56
@hartbit
Copy link
Contributor Author

hartbit commented Feb 18, 2019

@nkcsgexi done!

@hartbit hartbit changed the title Make Trivia and TriviaPiece Equatable and Hashable Make Trivia and TriviaPiece Equatable Feb 18, 2019
@nkcsgexi
Copy link
Contributor

@swift-ci please test

1 similar comment
@nkcsgexi
Copy link
Contributor

@swift-ci please test

@nkcsgexi nkcsgexi merged commit 4440e57 into swiftlang:master Feb 19, 2019
adevress pushed a commit to adevress/swift-syntax that referenced this pull request Jan 14, 2024
Use a closure instead of a keypath in a call to `map`.
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.

2 participants