Open swift-ci opened 4 years ago
@swift-ci create
This will compile if you use coercion instead of a conditional cast:
if let value = self.value() as T? {
A conditional cast x as? T
happens at runtime, so the type checker doesn't use the type that you're casting to when inferring the type of x
- it has to be able to infer the type of x
independently.
Coercion is the way to specify a generic argument when the type parameter is the return type of the generic function.
This is really subtle though, and the diagnostic can definitely be improved!
Attachment: Download
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | | |Labels | Improvement | |Assignee | None | |Priority | Medium | md5: 5da667e3486520c170e5ec6a1bef9e08Issue Description:
Simple case: