-
Notifications
You must be signed in to change notification settings - Fork 145
Description
This caused me some grief with recent update to Xcode 11 GM. Somehow, Swift (5.1) started re-ordering some of DynamicColor's math expressions to use + and - overloads I had created to handle mixing CGFloat and Int without the need to cast. This was possible because DynamicColor code and mine are in the same module. Strangely, this did not occur before Swift 5.1
The change in Swift's behavior caused major breakage in my app colors, because the math expressions became incorrect -- for example, let r = hueToRGB(m1: m1, m2: m2, h: h + 1 / 3) would compute h + 1 before / 3.
Notwithstanding the dumbness of my operator overloads (!), I think DynamicColor should make these expressions more explicit to shield future problems from occurring.
Using that same example, change:
let r = hueToRGB(m1: m1, m2: m2, h: h + 1 / 3)
to
let r = hueToRGB(m1: m1, m2: m2, h: h + (1.0 / 3.0))
And of course, other places where similar precedence problems may occur.
I would be happy to create the pull request for this as soon as I have a moment. Else, if someone else does I'd be happy to review it.