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-1430] Swift 3 no longer automatically coerces Double literal argument to CGFloat #44039
Comments
I can't reproduce this in simple tests—not quite the situation you're setting up, but just |
@belkadan I can reproduce reliably in an actual iOS project. I've uploaded one. It's basically a one-liner: import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
_ = UIColor(red:0.5, green:0.6, blue:0.7, alpha:1.0) // error
}
} This is Xcode in El Capitan with the 05-03 toolchain, so if you don't see the same thing, maybe it's been fixed in the daily build? |
I'm still not seeing this. Xcode 7.3.1 (7D1014), with iOS SDK 13E238 ( …aha, wait, it compiles cleanly, but Live Issues is showing an error. And now I see we have an overload that takes |
The "compiles cleanly" part is a bit strange too. Might be compiler non-determinism. |
Interestingly, I can work around this by casting just the first argument, i.e. |
I believe that this is a known bug (that we really need to fix) where the initializer for the playground literal for colors is ambiguous with the normal init. We should rename the init method in the playground literal protocol. |
@rjmccall did you just fix this? |
Yes, this is fixed now. |
Thanks, now that the May 31 toolchain is out I can confirm this is fixed. |
Attachment: Download
Environment
Xcode 7.3.1 Toolchain: Swift Development Snapshot 2016-05-03 (a)
Additional Detail from JIRA
md5: 66ca49b2b3122af47873b7d0d5624894
is duplicated by:
Issue Description:
This code, which has compiled since the dawn of Swift, no longer compiles in Swift 3:
The error message is: "Ambiguous use of
init(red:green:blue:alpha:)
". But there is no such ambiguity.I can work around the problem by explicitly coercing all those Double literals to CGFloat, but I shouldn't have to.
The text was updated successfully, but these errors were encountered: