interface A { val parent: A? } fun A.ext(): Int = 1 + (parent?.ext() ?: 0)