mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user