Added test that Optional.none is correctly cast in a generic context.

This commit is contained in:
Mathew Polzin
2019-02-11 09:02:06 -08:00
parent 3d05edd239
commit a974aaaabc

View File

@@ -43,7 +43,7 @@ CastsTests.test("No overrelease of existential boxes in failed casts") {
}
}
}
let err: Error = ErrClass()
bar(err)
}
@@ -70,6 +70,16 @@ CastsTests.test("Multi-level optionals can be casted") {
testFailure(42, from: Int???.self, to: String.self)
}
// Test for SR-9837: Optional<T>.none not casting to Optional<U>.none in generic context
CastsTests.test("Optional<T>.none can be casted to Optional<U>.none in generic context") {
func test<T>(_ type: T.Type) -> T? {
return Any?.none as? T
}
expectEqual(type(of: test(Bool.self)), Bool?.self)
expectEqual(type(of: test(Bool?.self)), Bool??.self)
}
#if _runtime(_ObjC)
extension CFBitVector : P {
static func makeImmutable(from values: Array<UInt8>) -> CFBitVector {