interface IFoo { val A.foo: B get(): B { return B } } interface IInvoke { operator fun B.invoke(): Int { return 42 } } object A { private constructor() /* primary */ { super/*Any*/() /* () */ } } object B { private constructor() /* primary */ { super/*Any*/() /* () */ } } fun test(fooImpl: IFoo, invokeImpl: IInvoke) { with(receiver = A, block = local fun A.(): Int { return with(receiver = fooImpl, block = local fun IFoo.(): Int { return with(receiver = invokeImpl, block = local fun IInvoke.(): Int { return ($this$with, ($this$with, $this$with).()).invoke() } ) } ) } ) /*~> Unit */ }