Skip to content

Commit 8a2960f

Browse files
authored
Merge pull request #26029 from lorentey/fix-abi-breaks
[Darwin] Fix ABI breaks introduced since 5.0
2 parents 81a69f3 + 315e865 commit 8a2960f

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

stdlib/public/Darwin/CoreGraphics/CGFloat.swift.gyb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ extension CGFloat : Hashable {
397397
hasher.combine(native)
398398
}
399399

400-
@inlinable @_transparent
400+
@_alwaysEmitIntoClient @inlinable // Introduced in 5.1
401401
public func _rawHashValue(seed: Int) -> Int {
402402
return native._rawHashValue(seed: seed)
403403
}

stdlib/public/Darwin/Foundation/NSStringEncodings.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,31 @@ extension String {
5151
}
5252

5353
extension String.Encoding : Hashable {
54+
public var hashValue: Int {
55+
// Note: This is effectively the same hashValue definition that
56+
// RawRepresentable provides on its own. We only need to keep this to
57+
// ensure ABI compatibility with 5.0.
58+
return rawValue.hashValue
59+
}
60+
61+
@_alwaysEmitIntoClient // Introduced in 5.1
5462
public func hash(into hasher: inout Hasher) {
63+
// Note: `hash(only:)` is only defined here because we also define
64+
// `hashValue`.
65+
//
66+
// In 5.0, `hash(into:)` was resolved to RawRepresentable's functionally
67+
// equivalent definition; we added this definition in 5.1 to make it
68+
// clear this `hash(into:)` isn't synthesized by the compiler.
69+
// (Otherwise someone may be tempted to define it, possibly breaking the
70+
// hash encoding and thus the ABI. RawRepresentable's definition is
71+
// inlinable.)
5572
hasher.combine(rawValue)
5673
}
5774

5875
public static func ==(lhs: String.Encoding, rhs: String.Encoding) -> Bool {
76+
// Note: This is effectively the same == definition that
77+
// RawRepresentable provides on its own. We only need to keep this to
78+
// ensure ABI compatibility with 5.0.
5979
return lhs.rawValue == rhs.rawValue
6080
}
6181
}

0 commit comments

Comments
 (0)