Swift 2.1 expression too complex

Originator:keithbsmiley
Number:rdar://23421488 Date Originated:05-Nov-2015 03:34 PM
Status:Resolved Resolved:Xcode 9 beta 6
Product:Developer Tools Product Version:Swift 2.1
Classification:Other Bug Reproducible:Always
 
Summary:

Swift produces an expression too complex error with this `UIColor`
extension (also attached).

```swift
import UIKit

extension UIColor {
    var isVeryBright: Bool {
        let components = CGColorGetComponents(self.CGColor)
        let colorBrightness = ((components[0] * 299) + (components[1] * 587) + (components[2] * 114)) / 1000
        return colorBrightness > 0.8
    }
}
```

Steps to reproduce:

1. Attempt to compile this code with Xcode 7.1

Expected results:

The code compiles

Actual results:

```
error: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
```

Notes:

- Breaking this up into 3 separate expressions solves the problem
- Run with: `xcrun --sdk iphonesimulator swiftc UIColorTooComplex.swift`

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!