Merge pull request #63500 from tbkka/tbkka-rdar90269352-unwrap-AnyHashable

Add a test to verify that AnyHashable gets eagerly unwrapped
This commit is contained in:
swift-ci
2023-02-07 16:57:25 -08:00
committed by GitHub

View File

@@ -1051,4 +1051,17 @@ CastsTests.test("Do not overuse __SwiftValue (non-ObjC)") {
expectNotNil(runtimeCast(b, to: Foo.self))
}
CastsTests.test("Don't put AnyHashable inside AnyObject") {
class C: Hashable {
func hash(into hasher: inout Hasher) {}
static func ==(lhs: C, rhs: C) -> Bool { true }
}
let a = C()
let b = AnyHashable(a)
let c = a as! AnyObject
expectTrue(a === c)
let d = c as! C
expectTrue(a === d)
}
runAllTests()