class A { ~A.foo~fun foo() = 1 } class B { } ~B.foo~fun B.foo() = 2 fun test(a: A, b: B) { with (a) { with (b) { `B.foo`foo() } } } fun with(receiver: T, f: T.() -> R) : R = receiver.f()