this during object construction including:
this as a function argument in a constructor of a non-final classIf other classes inherit from the given class, they may not be fully initialized at the moment when an unsafe operation is carried out.
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
}