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-7939] Spurious Warning when down casting to [String] #50474

Closed
swift-ci opened this issue Jun 8, 2018 · 1 comment
Closed

[SR-7939] Spurious Warning when down casting to [String] #50474

swift-ci opened this issue Jun 8, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jun 8, 2018

Previous ID SR-7939
Radar None
Original Reporter rauhul (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Version 10.0 beta (10L176w)

Toolchain: Swift Development Snapshot 2018-06-07 (a)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: bebede5cb57c798cb1074f352feab4f5

duplicates:

  • SR-7906 assigning cast value to implicitly unwrapped Optional causes (bogus?) warning

Issue Description:

The following code should not produce a warning, but does

guard let symbols = _shortStandaloneWeekdaySymbols else {
    let cfSymbols = CFDateFormatterCopyProperty(_cfObject, kCFDateFormatterShortStandaloneWeekdaySymbols) as! NSArray
    return cfSymbols.allObjects as! [String] // produces warning
}  

swift-corelibs-foundation/Foundation/DateFormatter.swift:399: Treating a forced downcast to '[String]' as optional will never produce 'nil'

replacing the offending line with the following removes the warning

return (cfSymbols.allObjects as? [String])!
@belkadan
Copy link
Contributor

belkadan commented Jun 9, 2018

The piece that's missing here is that the result type is an IUO. We've had a few other reports of this; I'll find the dup(s) later.

@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
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants