You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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))
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.
The text was updated successfully, but these errors were encountered:
Environment
May 3rd dev toolchain
Additional Detail from JIRA
md5: a25a70aa5477dae6638e8e0db25ebf86
duplicates:
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.
The text was updated successfully, but these errors were encountered: