New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-4377] Swift 3.1 regression with conditional casting to protocol #46956
Comments
@swift-ci create |
I'm failing to reproduce this with exactly the same setup. Argh! |
That sucks :/
|
I attached some screenshots from the real setup. Hopefully you see something I'm not thinking off that's making the difference. |
FYI this is still an issue with Swift 4.0.2 (the workaround still works though): func cast<T, U>(_ x: T, to: U.Type) -> U? {
return x as? U
}
if let reportableError = cast(error.error, to: ReportableError.self) { ... } |
What was your workaround? |
@jckarter the one you gave me back then 🙂 (I updated my comment). |
Sorry, it's been a while. So the |
That's correct. And I just checked with optimization and as? still produces Conditional cast from 'Error' to 'ReportableError' always succeeds. |
This still reproduces in Swift 4.1. |
Appears fixed in Swift 5.1 |
Attachment: Download
Environment
Swift version 3.1 (swiftlang-802.0.48 clang-802.0.38)
Swift version 4.0.2 (swiftlang-900.0.69.1 clang-900.0.38)
Swift version 4.1 (swiftlang-902.0.38 clang-902.0.31)
Additional Detail from JIRA
md5: 0121f0ca456189104247c42e9e89b1b8
is duplicated by:
Issue Description:
See screenshots.
The setup:
Expected result (worked in Swift 3.0.x): cast compiles and succeeds.
Actual result: Error "Conditional cast from 'Error' to 'ReportableError' always succeeds".
The text was updated successfully, but these errors were encountered: