Skip to content
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

[KeyPath] Fix regression in == on keypaths #73347

Merged
merged 1 commit into from May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions stdlib/public/core/KeyPath.swift
Expand Up @@ -237,12 +237,10 @@ extension AnyKeyPath: Hashable {
if a === b {
return true
}
/*
// Short-circuit differently-typed key paths
if type(of: a) != type(of: b) {
return false
}
*/
return a.withBuffer {
var aBuffer = $0
return b.withBuffer {
Expand Down
8 changes: 8 additions & 0 deletions test/stdlib/KeyPath.swift
Expand Up @@ -327,6 +327,14 @@ keyPath.test("computed properties") {
}
}

keyPath.test("equality") {
expectNotEqual(\Array<String>.isEmpty, \Substring.isEmpty)
expectNotEqual(\Array<String>.isEmpty, \Substring.isEmpty)
expectNotEqual(\Array<String>.isEmpty, \String.isEmpty)
expectNotEqual(\Array<String>.isEmpty, \Substring.last)
expectNotEqual(\Array<String>.isEmpty, \Array<Substring>.isEmpty)
}

class AB {
}
class ABC: AB, ABCProtocol {
Expand Down