What is happening here? Accessing null inside class???
class Test (var something: String){ // Compiler warns: Receiver parameter is never used // But it is necessary to let the following work. val Test?.something get() = "CCC" fun someMethode() { var test: Test? = null println(test.something) // works, prints CCC println(null.something) // works also, prints CCC test = Test("BBB") println(test.something) // now prints BBB test = null println(test.something) // now prints again CCC } } fun main() { val test1 = Test("AAA") println(test1.something) // prints AAA test1.someMethode() val test2: Test? = null // println(test2.something) won't compile } https://code.sololearn.com/cl4aFZji8eE8/?ref=app