Here is another slow expression to demonstrate the disjunction pruning optimization I talked about earlier.

Suppose you declare a variable of implicitly unwrapped optional type:

var x: Int! = ...

The value of x is stored like an ordinary optional "Int?", but a reference to x from inside an expression is presented as a disjunction---the type of the reference is either "Int", or "Int?". If both lead to a solution, we favor the "Int?" choice; otherwise, we get the "Int" choice, and the compiler then lowers the reference to a runtime check.

Now, consider this expression:

let result = x + x + x + x + x + x

It takes the Swift 6.3 compiler a third of a second to type check this expression, and now its instant with recent main snapshots. What changed?

0

If you have a fediverse account, you can quote this note from your own instance. Search https://mathstodon.xyz/users/slava/statuses/116216756957915473 on your instance and quote it. (Note that quoting is not supported in Mastodon.)