Dissecting Kotlin: Finding Safety
summary
Kotlin’s recent changes tie exhaustiveness, smart casts and type inference together so the compiler actually uses surrounding checks to avoid dead else branches. A new opt‑in data flow-based exhaustiveness feature lets a when expression be exhaustive after prior if‑guards (example: a 5‑value enum for crew health), removing boilerplate and hidden bugs. The contracts API encodes predicates into the compiler so callers avoid unsafe casts and gain the same positive/negative type info that enables reliable smart casts.
AI-written summary · about
chapters (9)
- 0:00Kotlin safety intro
- 1:15Kotlin’s safety defaults
- 4:12Kotlin’s when expression
- 12:27Exhaustiveness in when
- 20:06Smart casts in Kotlin
- 31:09Data-flow exhaustiveness
- 36:28Contracts for compiler safety
- 40:21Null safety in Kotlin
- 41:45Summary: prioritize safety








