Is this a known gotcha?: <https://try.kotlinlang.o...
# announcements
s
Yup, Similar to
Copy code
abstract class A(val a: A?)

object B: A(C)
object C: A(B)
...
println("${B.a} and ${C.a}")
It’s a circular definition. The loading of the classes by the JVM determines which will be
null
and which will be properly initialized.
e
I wouldn't hate the editor and/or compiler generate a warning in this case
s
It may slow the compiler down too much if it has to analyze the code for this type of situation. In the above example, the circular definition is trivial and simple, but you can make a circular definition very deep and non-trivial.