@@ -98,8 +98,14 @@ func TestHashable<T: Hashable>(_ h: T)
98
98
// Test Obj-C hashValue for Swift types that are Equatable but not Hashable
99
99
func TestEquatableHash< T: Equatable > ( _ e: T )
100
100
{
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
102
107
TestSwiftValueNSObjectHashValue ( e as AnyObject , 1 )
108
+ #endif
103
109
}
104
110
105
111
func TestNonEquatableHash< T> ( _ e: T )
@@ -113,10 +119,6 @@ func TestNonEquatableHash<T>(_ e: T)
113
119
// CHECK-NEXT: d ##This is D's description##
114
120
// CHECK-NEXT: S ##{{.*}}__SwiftValue##
115
121
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
-
120
122
// Temporarily disable this test on older OSes until we have time to
121
123
// look into why it's failing there. rdar://problem/47870743
122
124
if #available( OSX 10 . 12 , iOS 10 . 0 , * ) {
@@ -156,6 +158,4 @@ if #available(OSX 10.12, iOS 10.0, *) {
156
158
fputs ( " c ##This is C's debug description## \n " , stderr)
157
159
fputs ( " d ##This is D's description## \n " , stderr)
158
160
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)
161
161
}
0 commit comments