This inspection reports dangerous operations inside constructors including:
Accessing non-final property in constructor
Calling non-final function in constructor
Using 'this' as function argument in constructor of non-final class
These operations are dangerous because your class can be inherited,
and derived class is not yet initialized at this moment. Typical example:
abstract class Base {
val code = calculate()
abstract fun calculate(): Int
}
class Derived(private val x: Int) : Base() {
override fun calculate() = x
}
fun testIt() {
println(Derived(42).code) // Expected: 42, actual: 0
}