mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Added test that Optional.none is correctly cast in a generic context.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user