Environment
Xcode version 9.1 (9B55)
Swift 4
Tested in Swift Playgrounds on iOS too
Additional Detail from JIRA
| | |
|------------------|-----------------|
|Votes | 0 |
|Component/s | Standard Library |
|Labels | Bug |
|Assignee | None |
|Priority | Medium |
md5: 8bf4f977f4fc88a46b367d7a04a9bb0f
Issue Description:
struct A<Message> {
func received(message: Any?) {
if let message = message as? Message {
print("success")
} else {
print("fail")
}
}
}
let a = A<Int?>()
a.received(message: nil)
In above example I didn't find a way to recognise message as generic type when that type is an optional.
Expected:
When generic type Message is Optional casting nil as? Message should always succeed with nil result.
Environment
Xcode version 9.1 (9B55) Swift 4 Tested in Swift Playgrounds on iOS tooAdditional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Standard Library | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 8bf4f977f4fc88a46b367d7a04a9bb0fIssue Description:
In above example I didn't find a way to recognise message as generic type when that type is an optional.
Expected:
When generic type Message is Optional casting nil as? Message should always succeed with nil result.
Actual result:
Casting fails.