diff --git a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/JsInliner.java b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/JsInliner.java index 89800bbefff..1b88c5d3267 100644 --- a/js/js.inliner/src/org/jetbrains/kotlin/js/inline/JsInliner.java +++ b/js/js.inliner/src/org/jetbrains/kotlin/js/inline/JsInliner.java @@ -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--; diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java index 56457473294..3b248f07322 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java @@ -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"); diff --git a/js/js.translator/testData/box/inlineMultiModule/topLevelNestedInline.kt b/js/js.translator/testData/box/inlineMultiModule/topLevelNestedInline.kt new file mode 100644 index 00000000000..10909ffc99c --- /dev/null +++ b/js/js.translator/testData/box/inlineMultiModule/topLevelNestedInline.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()) \ No newline at end of file