@@ -98,8 +98,14 @@ func TestHashable<T: Hashable>(_ h: T)
9898// Test Obj-C hashValue for Swift types that are Equatable but not Hashable
9999func TestEquatableHash< T: Equatable > ( _ e: T )
100100{
101- // These should have a constant hash value
101+ #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS)
102+ // Legacy behavior used the pointer value, which is
103+ // incompatible with user-defined equality.
104+ TestSwiftValueNSObjectDefaultHashValue ( e as AnyObject )
105+ #else
106+ // New behavior uses a constant hash value in this case
102107 TestSwiftValueNSObjectHashValue ( e as AnyObject , 1 )
108+ #endif
103109}
104110
105111func TestNonEquatableHash< T> ( _ e: T )
@@ -113,10 +119,6 @@ func TestNonEquatableHash<T>(_ e: T)
113119// CHECK-NEXT: d ##This is D's description##
114120// CHECK-NEXT: S ##{{.*}}__SwiftValue##
115121
116- // Full message is longer, but this is the essential part...
117- // CHECK-NEXT: Obj-C `-hash` {{.*}} type `SwiftValueNSObject.E` {{.*}} Equatable but not Hashable
118- // CHECK-NEXT: Obj-C `-hash` {{.*}} type `SwiftValueNSObject.E1` {{.*}} Equatable but not Hashable
119-
120122// Temporarily disable this test on older OSes until we have time to
121123// look into why it's failing there. rdar://problem/47870743
122124if #available( OSX 10 . 12 , iOS 10 . 0 , * ) {
@@ -156,6 +158,4 @@ if #available(OSX 10.12, iOS 10.0, *) {
156158 fputs ( " c ##This is C's debug description## \n " , stderr)
157159 fputs ( " d ##This is D's description## \n " , stderr)
158160 fputs ( " S ##__SwiftValue## \n " , stderr)
159- fputs ( " Obj-C `-hash` ... type `SwiftValueNSObject.E` ... Equatable but not Hashable " , stderr)
160- fputs ( " Obj-C `-hash` ... type `SwiftValueNSObject.E1` ... Equatable but not Hashable " , stderr)
161161}
0 commit comments