I don't understand if this is expected behavior
class A { val fields = object { val hello = "hello" } fun foo() { val hello = fields.hello // unresolved reference: hello val f = object { val hello = "hello" } val hello2 = f.hello // compiles fine } }
Apparently, this.fields resolves to kotlin.Any, while the local val f to the anonymous object of type mypackage.A.foo.<no name specified> which is the same I would expect for A.fields