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-1479] UIColor Float-based initializer shouldn't be there #44088

Closed
swift-ci opened this issue May 11, 2016 · 0 comments
Closed

[SR-1479] UIColor Float-based initializer shouldn't be there #44088

swift-ci opened this issue May 11, 2016 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

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

May 3rd dev toolchain

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

md5: a25a70aa5477dae6638e8e0db25ebf86

duplicates:

  • SR-1430 Swift 3 no longer automatically coerces Double literal argument to CGFloat

Issue Description:

Discovered on the Swift-User list that UIColor in the most recent May 3rd toolchain supports initializers for both Float and CGFloat. Which is odd: Bit of a problem because Xcode complains about an “Ambiguous use of init(red:green:blue:alpha🙂”. No kidding. So right now, you have to cast everything, e.g.

let color = UIColor(red: CGFloat(0.5), green: CGFloat(0.5), blue: CGFloat(0.5), alpha: CGFloat(1.0))

Or you can do something really stupid like this:

{{extension Double {
var cg: CGFloat { return CGFloat(self) }
}

class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let c = UIColor(red: 0.5.cg, green: 0.5, blue: 0.5, alpha: 0.5)
}
}}}
It works but ew. Who ever uses Float with UIColor to begin with and why did this pop up in the latest build? Is it part of the Cocoa auto-migration thing?

Can you please take it out? 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
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

1 participant