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-11434] False positive warning: cast always fails from 'Encodable' to 'NSDecimalNumber'/'[String: Encodable]' #53835

Closed
stephentyrone opened this issue Sep 7, 2019 · 5 comments
Labels
compiler The Swift compiler in itself

Comments

@stephentyrone
Copy link
Member

Previous ID SR-11434
Radar None
Original Reporter @stephentyrone
Type Sub-task
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Sub-task
Assignee None
Priority Medium

md5: 8b7ddb293d9ac1d4acfdae5edc9c5230

Parent-Task:

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

Issue Description:

Observed on fairly recent master:

/Volumes/Data/Checkouts/Swift/swift/stdlib/public/Darwin/Foundation/JSONEncoder.swift:928:27: warning: cast from 'Encodable' to unrelated type 'NSDecimalNumber' always fails
return (value as! NSDecimalNumber)
~~~~~ ^ ~~~~~~~~~~~~~~~
/Volumes/Data/Checkouts/Swift/swift/stdlib/public/Darwin/Foundation/JSONEncoder.swift:930:39: warning: cast from 'Encodable' to unrelated type '[String : Encodable]' always fails
return try self.box(value as! [String : Encodable])
~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~

Either the warning is wrong, or this is a bug in the overlay.

@stephentyrone
Copy link
Member Author

Tagging both Compiler and Foundation until someone investigates to decide who's wrong.

@belkadan
Copy link
Contributor

belkadan commented Sep 9, 2019

The compiler is wrong. Someone just fixed something in this area…@theblixguy, do you remember who it was?

@theblixguy
Copy link
Collaborator

I did recently tweaked the code around casts from a protocol type to a non-protocol type, but my change disabled the diagnostic for situations when we're casting from a protocol type to a non-final class (see #26971), so the first diagnostic should not be produced anymore.

@belkadan
Copy link
Contributor

belkadan commented Sep 9, 2019

Okay, so this is probably "continues to be broken" rather than "was recently broken".

@LucianoPAlmeida
Copy link
Collaborator

@stephentyrone this is fixed on master, can you please verify on the next available snapshot and close? Thanks 🙂

@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
Projects
None yet
Development

No branches or pull requests

4 participants