fix: function inlining without blocks for else statement.
This commit is contained in:
@@ -746,7 +746,7 @@ public class JsToStringGenerationVisitor extends JsVisitor {
|
||||
space();
|
||||
}
|
||||
sourceLocationConsumer.pushSourceInfo(null);
|
||||
accept(elseStatement);
|
||||
accept(materialize(elseStatement));
|
||||
sourceLocationConsumer.popSourceInfo();
|
||||
if (!elseIf) {
|
||||
nestedPop(elseStatement);
|
||||
|
||||
@@ -4574,6 +4574,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/inline/astCopy.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("blocksMaterialization.kt")
|
||||
public void testBlocksMaterialization() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/blocksMaterialization.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callFunction.kt")
|
||||
public void testCallFunction() throws Exception {
|
||||
|
||||
+6
@@ -4952,6 +4952,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/inline/astCopy.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("blocksMaterialization.kt")
|
||||
public void testBlocksMaterialization() throws Exception {
|
||||
runTest("js/js.translator/testData/box/inline/blocksMaterialization.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("callFunction.kt")
|
||||
public void testCallFunction() throws Exception {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
// EXPECTED_REACHABLE_NODES: 1282
|
||||
package foo
|
||||
|
||||
inline fun dangerCall() {
|
||||
assertEquals("A", "A")
|
||||
assertNotEquals("A", "A")
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
if ("A" != "A") dangerCall()
|
||||
|
||||
if ("A" == "A") {
|
||||
// Nothing to do
|
||||
} else dangerCall()
|
||||
|
||||
while ("A" != "A") dangerCall()
|
||||
|
||||
for (num in 0 until 0) dangerCall()
|
||||
|
||||
when ("A") {
|
||||
"A" -> {}
|
||||
else -> dangerCall()
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user