Skip to content

Conversation

@lorentey
Copy link
Member

@lorentey lorentey commented Aug 2, 2018

NSURLComponents inherits hash from NSObject, but overrides isEqual(_:) to compare contents. The default hash uses object identity, so two NSURLComponent instances that compare equal under isEqual(_:) can produce non-equal hash values. This also breaks hashing for URLComponents, which calls into NSURLComponents.hash.

Add an implementation for NSURLComponents.hash that matches isEqual(_:).

Resolves https://bugs.swift.org/browse/SR-8450

@lorentey lorentey requested review from millenomi and parkera August 2, 2018 14:07
@lorentey
Copy link
Member Author

lorentey commented Aug 2, 2018

@swift-ci please test



func test_hash() {
let c1 = URLComponents(string: "https://www.swift.org/path/to/file.html?id=name")!
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as in the other review, can we test changing all parts that contribute to the hash?

@lorentey
Copy link
Member Author

lorentey commented Aug 6, 2018

Closing; please see followup PR at #1656

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