Fix bug in new JS inliner when inlining nested calls

This commit is contained in:
Alexey Andreev
2017-08-22 14:22:29 +03:00
parent 63855af026
commit 593aa72439
3 changed files with 29 additions and 0 deletions
@@ -279,6 +279,10 @@ public class JsInliner extends JsVisitorWithContextImpl {
reportInlineCycle(call, definition.getFunction());
}
else if (!processedFunctions.contains(definition.getFunction())) {
for (int i = 0; i < call.getArguments().size(); ++i) {
JsExpression argument = call.getArguments().get(i);
call.getArguments().set(i, accept(argument));
}
inlineFunctionDepth++;
visit(definition);
inlineFunctionDepth--;
@@ -4856,6 +4856,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
doTest(fileName);
}
@TestMetadata("topLevelNestedInline.kt")
public void testTopLevelNestedInline() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inlineMultiModule/topLevelNestedInline.kt");
doTest(fileName);
}
@TestMetadata("typealiases.kt")
public void testTypealiases() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("js/js.translator/testData/box/inlineMultiModule/typealiases.kt");
@@ -0,0 +1,19 @@
// EXPECTED_REACHABLE_NODES: 995
// MODULE: lib
// FILE: lib1.kt
inline fun foo() = "OK"
inline fun bar(x: String) = "($x)"
// MODULE: main(lib)
// FILE: main.kt
// CHECK_NOT_CALLED: foo
// CHECK_NOT_CALLED: bar
fun box(): String {
if (prop != "(OK)") return "fail: $prop"
return "OK"
}
val prop = bar(foo())