Closed
Description
Previous ID | SR-3505 |
Radar | None |
Original Reporter | goldsdad (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Done |
Attachment: Download
Environment
OS X 10.11.6 (15G1212)
Xcode 8.2 (8C38)
IBM Swift Sandbox - Swift Ver. 3.0.2 (Release) - Platform: Linux (x86_64)
Additional Detail from JIRA
Votes | 1 |
Component/s | Standard Library |
Labels | Bug, TypeChecker |
Assignee | @slavapestov |
Priority | Medium |
md5: e9915be07f69d31b7fe68a41773d1454
relates to:
- SR-6192 Spurious "Cast from ... to unrelated type ... always fails" warning when implicitly converting an empty collection
Issue Description:
The output from the following code is reasonable to me except for the last line producing "true".
enum Foo<T> {
case some(T)
case none
}
print( Foo<Int>.some(3) is Foo<Int> ) // output: true
print( Foo<Int>.some(3) is Foo<String> ) // output: false
print( Foo<Int>.none is Foo<Int> ) // output: true
print( Foo<Int>.none is Foo<String> ) // output: false
print( Optional<Int>.some(3) is Optional<Int> ) // output: true
print( Optional<Int>.some(3) is Optional<String> ) // output: false
print( Optional<Int>.none is Optional<Int> ) // output: true
print( Optional<Int>.none is Optional<String> ) // output: true
The compiler even issues warning "Cast from 'Optional<Int>' to unrelated type 'Optional<String>' always fails" for the last line, as it does for the lines producing "false", yet the result is "true".