From 6765d6fa815503b90e100d553ec169e194f1440e Mon Sep 17 00:00:00 2001 From: Philippe Hausler Date: Mon, 22 Aug 2016 15:25:12 -0700 Subject: [PATCH] Correct the expectation of _SwiftValue isEqual to properly handle the Any case --- Foundation/Bridging.swift | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Foundation/Bridging.swift b/Foundation/Bridging.swift index a43be5f8a0..76d07ab74a 100644 --- a/Foundation/Bridging.swift +++ b/Foundation/Bridging.swift @@ -120,19 +120,19 @@ internal final class _SwiftValue : NSObject, NSCopying { return ObjectIdentifier(self).hashValue } - override func isEqual(_ object: Any?) -> Bool { - guard let other = object as? NSObject else { - return false - } - if let box = other as? _SwiftValue { - if let otherHashable = box.value as? AnyHashable, - let hashable = value as? AnyHashable { - return hashable == otherHashable + override func isEqual(_ value: Any?) -> Bool { + if let other = value as? _SwiftValue { + if self === other { + return true } - } - if let otherHashable = other as? AnyHashable, - let hashable = value as? AnyHashable { - return hashable == otherHashable + if let otherHashable = other.value as? AnyHashable, + let hashable = self.value as? AnyHashable { + return otherHashable == hashable + } + + } else if let otherHashable = value as? AnyHashable, + let hashable = self.value as? AnyHashable { + return otherHashable == hashable } return false }