Skip to content
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-13081] False positive warning: cast always fails from 'JSON' to '[Any]' #55527

Closed
swift-ci opened this issue Jun 25, 2020 · 4 comments
Closed
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13081
Radar None
Original Reporter Olbo (JIRA User)
Type Sub-task
Status Closed
Resolution Done

Attachment: Download

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Sub-task, DiagnosticsQoI
Assignee None
Priority Medium

md5: 18498ba5ef9d32cf7041d969c9c90faa

Parent-Task:

  • SR-13088 False positive warning "cast always fails"

Issue Description:

protocol JSON { }
protocol JSONLeaf: JSON {}
extension Int: JSONLeaf { }
extension Array: JSON where Element: JSON { }
let x: JSON = [4] // [4]
let y = x as? [Any] // [4]

When the above is compiled a warning message will appear for the last line stating:

Cast from 'JSON' to unrelated type '[Any]' always fails

However, the typecast is successful printing the value `[4]` for y

I have reproduced this on Xcode 11.5 and verified it is still a bug on Xcode 12

@LucianoPAlmeida
Copy link
Collaborator

Also reproduced on a near master branch

@LucianoPAlmeida
Copy link
Collaborator

Olbo (JIRA User) this is fixed on master, can you please verify and close? Thanks 🙂

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jul 8, 2020

Comment by Oliver Atkinson (JIRA)

@LucianoPAlmeida I can verify this fix does resolve my problem inside of a swift package, however when running inside of a playground I am seeing the following crash. I am unsure if it's specific to the changes made. I used `swift-DEVELOPMENT-SNAPSHOT-2020-07-04-a.xctoolchain`

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jul 8, 2020

Comment by Oliver Atkinson (JIRA)

Issue is resolved on the latest trunk snapshot

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation
Projects
None yet
Development

No branches or pull requests

2 participants