Skip to content

Commit 66fad9f

Browse files
authored
Correct the expectation of _SwiftValue isEqual to properly handle the Any case (#582)
1 parent a478aaa commit 66fad9f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Foundation/Bridging.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,19 @@ internal final class _SwiftValue : NSObject, NSCopying {
120120
return ObjectIdentifier(self).hashValue
121121
}
122122

123-
override func isEqual(_ object: Any?) -> Bool {
124-
guard let other = object as? NSObject else {
125-
return false
126-
}
127-
if let box = other as? _SwiftValue {
128-
if let otherHashable = box.value as? AnyHashable,
129-
let hashable = value as? AnyHashable {
130-
return hashable == otherHashable
123+
override func isEqual(_ value: Any?) -> Bool {
124+
if let other = value as? _SwiftValue {
125+
if self === other {
126+
return true
131127
}
132-
}
133-
if let otherHashable = other as? AnyHashable,
134-
let hashable = value as? AnyHashable {
135-
return hashable == otherHashable
128+
if let otherHashable = other.value as? AnyHashable,
129+
let hashable = self.value as? AnyHashable {
130+
return otherHashable == hashable
131+
}
132+
133+
} else if let otherHashable = value as? AnyHashable,
134+
let hashable = self.value as? AnyHashable {
135+
return otherHashable == hashable
136136
}
137137
return false
138138
}

0 commit comments

Comments
 (0)