Skip to content

Commit e8341df

Browse files
committed
Merge pull request swiftlang#73552 from tbkka/tbkka-127839540
Make SwiftValue == support unconditional
1 parent 21b30a7 commit e8341df

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

stdlib/public/runtime/SwiftValue.mm

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,10 @@ - (BOOL)isEqual:(id)other {
430430
}
431431
}
432432

433-
if (runtime::bincompat::useLegacySwiftObjCHashing()) {
434-
// Legacy behavior only proxies isEqual: for Hashable, not Equatable
435-
return NO;
436-
}
433+
// if (runtime::bincompat::useLegacySwiftObjCHashing()) {
434+
// // Legacy behavior only proxies isEqual: for Hashable, not Equatable
435+
// return NO;
436+
// }
437437

438438
if (auto equatableConformance = selfHeader->getEquatableConformance()) {
439439
if (auto selfEquatableBaseType = selfHeader->getEquatableBaseType()) {
@@ -464,10 +464,10 @@ - (NSUInteger)hash {
464464
selfHeader->type, hashableConformance);
465465
}
466466

467-
if (runtime::bincompat::useLegacySwiftObjCHashing()) {
468-
// Legacy behavior doesn't honor Equatable conformance, only Hashable
469-
return (NSUInteger)self;
470-
}
467+
// if (runtime::bincompat::useLegacySwiftObjCHashing()) {
468+
// // Legacy behavior doesn't honor Equatable conformance, only Hashable
469+
// return (NSUInteger)self;
470+
// }
471471

472472
// If Swift type is Equatable but not Hashable,
473473
// we have to return something here that is compatible

test/stdlib/BridgeEquatableToObjC.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,7 @@ BridgeEquatableToObjC.test("Bridge equatable struct") {
3232
let objcResult = objcA.isEqual(objcB)
3333

3434
expectEqual(swiftResult, true)
35-
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
36-
// Apple platforms use old semantics for now...
37-
expectEqual(objcResult, false)
38-
#else
3935
expectEqual(objcResult, true)
40-
#endif
4136
}
4237

4338
BridgeEquatableToObjC.test("Bridge non-equatable struct") {

test/stdlib/SwiftValueNSObject.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,7 @@ func TestHashableEquals<T: Equatable>(_ e1: T, _ e2: T) {
9090
// This has not always been true for Equatable value types
9191
func TestEquatableEquals<T: Equatable>(_ e1: T, _ e2: T) {
9292
if e1 == e2 {
93-
#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(visionOS)
94-
// Legacy: Swift Equatable is not used in ObjC
95-
TestSwiftValueNSObjectNotEquals(e1 as AnyObject, e2 as AnyObject)
96-
#else
9793
TestSwiftValueNSObjectEquals(e1 as AnyObject, e2 as AnyObject)
98-
#endif
9994
} else {
10095
TestSwiftValueNSObjectNotEquals(e1 as AnyObject, e2 as AnyObject)
10196
}
@@ -114,14 +109,8 @@ func TestHashable<T: Hashable>(_ h: T)
114109
// Test Obj-C hashValue for Swift types that are Equatable but not Hashable
115110
func TestEquatableHash<T: Equatable>(_ e: T)
116111
{
117-
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)
118-
// Legacy behavior used the pointer value, which is
119-
// incompatible with user-defined equality.
120-
TestSwiftValueNSObjectDefaultHashValue(e as AnyObject)
121-
#else
122112
// New behavior uses a constant hash value in this case
123113
TestSwiftValueNSObjectHashValue(e as AnyObject, 1)
124-
#endif
125114
}
126115

127116
func TestNonEquatableHash<T>(_ e: T)

0 commit comments

Comments
 (0)