@BuilderInference and smart casts - should it work?

Looks like a bug that is already fixed in 1.4-M3.
If you don’t want to upgrade to an unstable version of kotlin you can use
sequence<T> { ... }. That way everything should work.