Is any difference between lambda expression and anonymous function?


#1

I personally assume that lambda expression and anonymous function share the same implementation, and the snippet below confuses me quite a lot.

// this compiles
inline fun bar(crossinline f: () -> Int) = { f() }

// this fails, error message says that such construction
// is not yet supported to be inlined
inline fun foo(crossinline f: () -> Int) = fun () = f()

What’s the problem that foo should be prevented to be compiled?


#2

There is no fundamental problem; the message is basically a bug in the Kotlin compiler. Please file a YouTrack issue, and we’ll fix it.