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-11842] All paths through this function will call itself with #available not giving warning for other path. #54247

Closed
swift-ci opened this issue Nov 24, 2019 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself diagnostics QoI Bug: Diagnostics Quality of Implementation SILOptimizer Area → compiler: SIL optimization passes

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 24, 2019

Previous ID SR-11842
Radar rdar://problem/57460599
Original Reporter neil.nothing (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Xcode version: 11.2.1 (11B500)

Swift version: 5.1

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

md5: 63c1f01418371041d642bf847d24c120

Issue Description:

For supporting new dark mode for iOS 13, using UIColor extension for the bifurcation of colors for other OS version as below.

import UIKit

extension UIColor {
    static var groupedBackground: UIColor {
        if #available(iOS 13, *) {
            return UIColor.systemGroupedBackground
        } else {
            return UIColor.groupedBackground
        }
    }
}

Here I get a typo for OS version not iOS 13, and will result in crash at run-time.

While if we try to write as below:

extension UIColor {
    static var groupedBackground: UIColor {
        return UIColor.groupedBackground  
    }
}

Here we get compile-time warning saying All paths through this function will call itself.

Expected Result:

  • We should present with the compile time warning for the other part in case of #available checks.
@beccadax
Copy link
Contributor

@swift-ci create

@eeckstein
Copy link
Member

fixed with #35368

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added diagnostics QoI Bug: Diagnostics Quality of Implementation SIL and removed SILDiagnostics SIL labels Nov 2, 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 diagnostics QoI Bug: Diagnostics Quality of Implementation SILOptimizer Area → compiler: SIL optimization passes
Projects
None yet
Development

No branches or pull requests

4 participants