There is a lateinit improvement in Kotlin 1.2 that allows to check the initialization state of lateinit variable directly:
lateinit var file: File
if (this::file.isInitialized) { ... }
See the annoucement on JetBrains blog or the KEEP proposal.
UPDATE: Kotlin 1.2 has been released. You can find lateinit enhancements here:
- Checking whether a lateinit var is initialized
- Lateinit top-level properties and local variables