Skip to content

Commit 4f3f73b

Browse files
authored
Merge pull request swiftlang#63500 from tbkka/tbkka-rdar90269352-unwrap-AnyHashable
Add a test to verify that AnyHashable gets eagerly unwrapped
2 parents 36ab596 + 5074504 commit 4f3f73b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/Casting/Casts.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,4 +1051,17 @@ CastsTests.test("Do not overuse __SwiftValue (non-ObjC)") {
10511051
expectNotNil(runtimeCast(b, to: Foo.self))
10521052
}
10531053

1054+
CastsTests.test("Don't put AnyHashable inside AnyObject") {
1055+
class C: Hashable {
1056+
func hash(into hasher: inout Hasher) {}
1057+
static func ==(lhs: C, rhs: C) -> Bool { true }
1058+
}
1059+
let a = C()
1060+
let b = AnyHashable(a)
1061+
let c = a as! AnyObject
1062+
expectTrue(a === c)
1063+
let d = c as! C
1064+
expectTrue(a === d)
1065+
}
1066+
10541067
runAllTests()

0 commit comments

Comments
 (0)