Consider the following functions:
fun Int.ext() {
// TODO
}
fun doSomething(f: Int.() -> Unit) {
// TODO
}
The functional parameter f has the same type as the extension function ext. So, I can do this:
doSomething(Int::ext)
The question is…
In the body of doSomething function, I can do this:
fun doSomething(f: Int.() -> Unit) {
42.f() // OK
f(42) // OK
}
But when I call the ext function, this happens:
42.ext() // OK
ext(42) // compiler error
Why does that happens? I thought that function types with receivers were the same thing as extension function types, but now I’m not sure.