Inline types and functions in Swift
swiftbysundell.com
swiftbysundell.com
In general Swift’s type inference can be slow, and seems to have bad time complexity. I suspect that for non trivial closures Swift falls back to requiring explicit typing so that type inference speed doesn’t become too much of an issue.
You can actually improve compile times somewhat by adding explicit typing for complex statements. There’s a compiler flag for logging compile time per function, and for large projects I’ve used this to identify and add typing for problematic lines (sometimes these lines each contributed to a few seconds of compile time).
[edit: fix grammar]