This Week I Learned: Smart Casts weird me out [2022–07–04]
Jul 8, 2022
Kotlin’s smart casts continue to weird me out, in a good way. It’s a reminder that the compiler doesn’t actually produce code that does what I can see on my screen, but rather what it chose to write into bytecode based on looking at my code and then deciding for itself. I can write a line of code that by itself is syntactically wrong and yet because of the lines around it they together become right.
The IDE knowing what the compiler will produce instead of being simply a text editor is
though — also in a good way.