fun getT(): T = null!! class Test { private fun foo() : I = getT() fun apply(i: I) {} init { foo() this.foo() } fun test() { apply(foo()) apply(this.foo()) with(Test()) { apply(foo()) // resolved to this@Test.foo apply(this.foo()) apply(this@with.foo()) apply(this@Test.foo()) } } fun test(t: Test) { t.apply(t.foo()) } companion object { fun test(t: Test) { t.apply(t.foo()) } } } fun test(t: Test) { t.apply(t.foo()) }