Skip to content

Commit 10073cb

Browse files
committed
[stdlib] Bool: Fix hashValue and remove @_transparent attribute.
1 parent 3ffceb9 commit 10073cb

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

stdlib/public/core/Bool.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,11 @@ extension Bool : Equatable, Hashable {
154154
/// invocations of the same program. Do not persist the hash value across
155155
/// program runs.
156156
@_inlineable // FIXME(sil-serialize-all)
157-
@_transparent
158157
public var hashValue: Int {
159-
return self ? 1 : 0
158+
return _hashValue(for: self)
160159
}
161160

162161
@_inlineable // FIXME(sil-serialize-all)
163-
@_transparent
164162
public func _hash(into hasher: _UnsafeHasher) -> _UnsafeHasher {
165163
return hasher.appending((self ? 1 : 0) as UInt8)
166164
}

test/Interpreter/SDK/equatable_hashable.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@ import Foundation
88

99
func testHash<H: Hashable>(_ x: H) -> Int { return x.hashValue }
1010

11+
// CHECK: (1 as UInt8): hash = [[HASH:-?[0-9]+]]
12+
print("(1 as UInt8): hash = \((1 as UInt8).hashValue)")
13+
1114
func test_CBool() {
1215
let x: CBool = true
1316
let hash = testHash(x)
1417
print("C_Bool: hash = \(hash)")
1518
}
16-
// CHECK: C_Bool: hash = 1
19+
// CHECK: C_Bool: hash = [[HASH]]
1720
test_CBool()
1821

1922
func test_ObjCBool() {
2023
let x = ObjCBool(true)
2124
let hash = testHash(x.boolValue)
2225
print("ObjCBool: hash = \(hash)")
2326
}
24-
// CHECK-NEXT: ObjCBool: hash = 1
27+
// CHECK-NEXT: ObjCBool: hash = [[HASH]]
2528
test_ObjCBool()
2629

2730
func testEquatable<E: Equatable>(_ x: E) {}

0 commit comments

Comments
 (0)