class Foo() { fun Int.invoke() {} } fun bar(f: Foo, i: Int) { with (i) { f() } } fun with(receiver: T, f: T.() -> R) : R = throw Exception()