Skip to content
This repository was archived by the owner on Jan 10, 2023. It is now read-only.

Commit bafa8cc

Browse files
committed
Merge branch 'main' of github.com:apple/swift into tensorflow-stage
* 'main' of github.com:apple/swift: Verify that nil can cast to AnyHashable (swiftlang#34434)
2 parents f5851fa + 7da78f7 commit bafa8cc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test/Casting/Casts.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,4 +761,12 @@ CastsTests.test("Async function types") {
761761
expectFalse(asyncFnType is (() -> Void).Type)
762762
}
763763

764+
// `Optional<Int>` is Hashable, so it must cast to AnyHashable,
765+
// even if it contains a nil. (This was broken in 5.3 and earlier,
766+
// but was fixed by the new dynamic cast runtime.)
767+
CastsTests.test("Optional nil -> AnyHashable") {
768+
let a : Int? = nil
769+
expectNotNil(a as? AnyHashable)
770+
}
771+
764772
runAllTests()

0 commit comments

Comments
 (0)