Pattern: Property used before declaration
Issue: -
Reports properties that are used before declaration.
Example of incorrect code:
class C {
private val number
get() = if (isValid) 1 else 0
val list = listOf(number)
private val isValid = true
}
fun main() {
println(C().list) // [0]
}
Example of correct code:
class C {
private val isValid = true
private val number
get() = if (isValid) 1 else 0
val list = listOf(number)
}
fun main() {
println(C().list) // [1]
}