[JS IR] Lower lambdas into in-line anonymous functions when possible
Previously we always generated factories for contextful lambdas:
```kt
fun foo(a: Int) = { a }
```
```js
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:
```js
function foo(a) {
return function() { return a; };
}
```
This commit is contained in:
@@ -356,6 +356,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/closure/closureArrayListInstance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closureCodeSize.kt")
|
||||
public void testClosureCodeSize() throws Exception {
|
||||
runTest("js/js.translator/testData/box/closure/closureCodeSize.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closureFunctionAsArgument.kt")
|
||||
public void testClosureFunctionAsArgument() throws Exception {
|
||||
|
||||
+6
@@ -356,6 +356,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/closure/closureArrayListInstance.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closureCodeSize.kt")
|
||||
public void testClosureCodeSize() throws Exception {
|
||||
runTest("js/js.translator/testData/box/closure/closureCodeSize.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closureFunctionAsArgument.kt")
|
||||
public void testClosureFunctionAsArgument() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user