I understand there's a wish to make Kotlin well suited for making DSL's just like the ones in Ruby and perhaps even Scala.
But I’m unsure about wether the current limitations are because of type infereness problems or grammar problems.
It seems that “bad1” below could suffer from the features used to omit parens, for example.
I found it amusing that the workaround with printInt2 seems to work fine, so it a grammar issue after all?
Too bad one can’t write a function “wrap” such as “wrap printInt” creates printInt2.
package Main
fun main(args: Array<String>) {
fun printInt(x: Int) = println(x)
// Trick to be able to use printInt below
fun printInt2() = {(x: Int) -> println(x) }
// There’s no support for this yet, recommendation is to
// use a function literal instead
val bad1 = printInt
val ok1 = printInt2()
// So, using a function literal, but “it” is unresolved despite full
// type information about printInt is available
val bad2 = { printInt(it) }
// While this works fine
val ok2: (Int) -> Unit = { printInt(it) }
}