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-6192] Spurious "Cast from ... to unrelated type ... always fails" warning when implicitly converting an empty collection #48744
Comments
cc @slavapestov, @atrick |
Arguably the cast should fail even if the collection is empty. Otherwise we cannot provide useful diagnostics here at all. We already have a silly corner case where casts between nil of unrelated types succeed... |
The runtime calls back to a Swift function that implements the cast. See _arrayConditionalCast in ArrayCast.swift.
Looks like we need to check not only the the element values are convertible, but also that the element types are somehow compatible. I'm not sure off hand how to do that. |
Ah, the Optional case was admitting we can't fix this; this is pretty much the same. @jckarter probably remembers better than me. |
(Sorry, I mean we can't have the casts fail. We can certainly fix the inconsistency.) |
I think @slavapestov's point was that either we make the casts fail or we never diagnose collection mis-casts. |
Fixed by #32716 which disables the warning. |
Environment
Apple Swift version 4.0 (swiftlang-900.0.65.2 clang-900.0.37)
Target: x86_64-apple-macosx10.9
Swift version 4.1-dev (LLVM a85c7fe628, Clang 12a3c42f5f, Swift 30a8e15)
Target: x86_64-apple-darwin17.0.0
Additional Detail from JIRA
md5: 37ede6070a91cc1f085f6a2ddc028af2
Parent-Task:
is duplicated by:
relates to:
Issue Description:
The following generates warnings, despite the implicit conversions succeeding at runtime:
The text was updated successfully, but these errors were encountered: