Search code examples
swiftxcodexcode10

type-check error after upgrading to Xcode 10


After upgrading to Xcode 10 and building my code

let nearestWedge: Int = Int(round(((currentRadians + (radiansPerWedge / 2)) + snappingPositionRadians) / radiansPerWedge))

I got this error:

The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions


Solution

  • This error appears when the swift compiler finds the expression too heavy to calculate it in a reasonable time

    just break your expression in sub expression; one example could be:

    let firstHalfOfExpression = (currentRadians + (radiansPerWedge / 2)) + snappingPositionRadians
    let nearestWedge: Int = Int(round(firstHalf / radiansPerWedge))