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-8037] Method generic type inference is broken in Swift 4.2 #50570
Comments
The code contains this line:
where Tianyong, you can work around this issue by using |
@swift-ci create |
Comment by Tianyong (JIRA)
Yes, I want to unwrap multiple layers of Optional here. Thank you for the workaround. |
Nothing changed in the runtime implementation of casting AFAIK. Is it type checking the expression differently? |
Comment by Tianyong (JIRA) When I cast `(try? body(self))` to `String` instead of the generic type `Result`, the value can be unwrapped out. Contrast the following two expressions:
The `Result.self == String.self` is true, but the value of later expression is nil. I think it's an unexpected behavior. |
Yes, looks like that to me. The underlying problem there was that the runtime function called for the generic version of the cast wouldn't unwrap more than one level of optional. This PR is the fix on the 4.2 branch: #16800 |
Attachment: Download
Environment
macOS High Sierra 10.13.4
Xcode 10.0 beta (10L176w) with Swift 4.2
Additional Detail from JIRA
md5: 1e942561e9c836589c1407f6f0931023
duplicates:
Issue Description:
My app built by Swift 4.2 is broken. I find it is related to method generic type reference.
The attachment is a test project which can reproduce this problem.
Build and run test project in Xcode 9.4, Swift 4.1. It will print "Hello" in console.
Build and run test project in Xcode 10.0 beta (10L176w), Swift 4.2. Nothing will be printed in console.
I don't know whether it is a bug or feature.
The text was updated successfully, but these errors were encountered: