Kotlin 1.7.10. I enable `-Xlambdas=indy`, but it s...
# getting-started
l
Kotlin 1.7.10. I enable
-Xlambdas=indy
, but it seems that kotlin compiler still produces Function class.
Copy code
fun main() {
    val a = 0
    l { println(a) }
}

fun l(block: () -> Unit) {
    block()
}
Will produce:
Copy code
NEW test/TestMainKt$main$1

public final static l(Lkotlin/jvm/functions/Function0;)V

final class test/TestMainKt$main$1 extends kotlin/jvm/internal/Lambda implements kotlin/jvm/functions/Function0
c
How is it enabled? In some cases (Gradle ‘kotlin-dsl’ is one) plugins set this in ‘afterEvaluate’.
l
Just
Copy code
tasks.withType<KotlinCompile> {
    kotlinOptions.freeCompilerArgs += "-Xlambdas=indy"
}
OK I know why, I use the builtin Kotlin bytecode viewer. It uses Jetbrains API for this feature, and I can tell that their machine doesn't turn on
-Xlambdas=indy
because this is how they return, while the real bytecode does produce invokedynamic.