-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itself
Description
Previous ID | SR-7664 |
Radar | rdar://problem/40171034 |
Original Reporter | @hamishknight |
Type | Bug |
Status | Resolved |
Resolution | Done |
Environment
Swift version 4.2-dev (LLVM d9cd6a5c49, Clang ed8876508e, Swift c363dad)
Target: x86_64-apple-darwin17.5.0
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 241ea289c2d537b07e80e0f58cf55573
is duplicated by:
- SR-8037 Method generic type inference is broken in Swift 4.2
Issue Description:
This cast succeeds:
func foo(_ t: Int??) -> Int? {
return t as? Int
}
let x = foo(Int??(3))
print(x as Any) // Optional(3)
but it fails when we use a generic placeholder satisfied by Int
rather than Int
directly. This cast fails:
func bar<U>(_ t: Int??, _: U.Type) -> U? {
return t as? U
}
let y = bar(Int??(3), Int.self)
print(y as Any) // nil
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itself