Skip to content

Commit 4e474d8

Browse files
authored
Merge pull request #73347 from kubamracek/keypath-fix-equality
[KeyPath] Fix regression in == on keypaths
2 parents f1539f1 + 1d48f28 commit 4e474d8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

stdlib/public/core/KeyPath.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,10 @@ extension AnyKeyPath: Hashable {
237237
if a === b {
238238
return true
239239
}
240-
/*
241240
// Short-circuit differently-typed key paths
242241
if type(of: a) != type(of: b) {
243242
return false
244243
}
245-
*/
246244
return a.withBuffer {
247245
var aBuffer = $0
248246
return b.withBuffer {

test/stdlib/KeyPath.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,14 @@ keyPath.test("computed properties") {
327327
}
328328
}
329329

330+
keyPath.test("equality") {
331+
expectNotEqual(\Array<String>.isEmpty, \Substring.isEmpty)
332+
expectNotEqual(\Array<String>.isEmpty, \Substring.isEmpty)
333+
expectNotEqual(\Array<String>.isEmpty, \String.isEmpty)
334+
expectNotEqual(\Array<String>.isEmpty, \Substring.last)
335+
expectNotEqual(\Array<String>.isEmpty, \Array<Substring>.isEmpty)
336+
}
337+
330338
class AB {
331339
}
332340
class ABC: AB, ABCProtocol {

0 commit comments

Comments
 (0)