I'm curious, why was `-Xir-generate-inline-anonymo...
# javascript
e
I'm curious, why was
-Xir-generate-inline-anonymous-functions
introduced? I can't find resources on it on the internet.
a
From the commit that introduced this flag: Previously we always generated factories for contextful lambdas like this:
Copy code
fun foo(a: Int) = { a }
Copy code
function foo(a_38) {
  return foo$lambda(a_38);
}

// factory!
function foo$lambda($a) {
  return function () {
    return $a;
  };
}
After this patch, the generated code for
foo
is more concise:
Copy code
function foo(a) {
  return function() { return a; };
}
t
Is it available in Kotlin
1.9.23
?
a
Yes, it should be available since
1.9.20
👍 1
t
Is there
-Xir-generate-js-arrow-functions-please
option? 🙂
😆 1
e
Thank you!
Btw, it seems it's not enabled by default. I wonder why not if it gives us a benefit.
t
It can be assumption of Gradle plugins, which process js-file before Webpack for example
I had such plugins before
@Artem Kobzar It works fine for parameters, but doesn't work for variables - is it expected?
e
Mmm interesting. You mean it doesn't capture local variables?
t
Copy code
fun fn1() {
    doCall {} // works fine, local function created

    val fn2 = {} // top-level function created
}
✔️ 1