[JS IR] Materialize Unit more aggressively for IrCalls

Unit materialization for IrCall is required for operations with dynamic type.

However it produces useless Unit_getInstance() calls,
especially in return expressions. The pach also adds some heuristics
for reducing the amount of Unit_getInstance() calls from return expressions:
do not add Unit_getInstance() if return value has Unit type.

Relaited to KT-51139
^KT-23252 Fixed
This commit is contained in:
Alexander Korepanov
2022-04-13 21:03:33 +03:00
committed by Space
parent 677ec12b50
commit 57f16e801f
6 changed files with 258 additions and 26 deletions
@@ -5352,6 +5352,12 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
runTest("js/js.translator/testData/box/inlineEvaluationOrder/propertyAccessAndInitializer.kt");
}
@Test
@TestMetadata("propertyAccessNoSideEffect.kt")
public void testPropertyAccessNoSideEffect() throws Exception {
runTest("js/js.translator/testData/box/inlineEvaluationOrder/propertyAccessNoSideEffect.kt");
}
@Test
@TestMetadata("propertyAccessWithSideEffect.kt")
public void testPropertyAccessWithSideEffect() throws Exception {
@@ -756,6 +756,18 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
runTest("js/js.translator/testData/box/coercion/unitMaterializationInOverriddenMethod.kt");
}
@Test
@TestMetadata("unitMaterializationOnAssign.kt")
public void testUnitMaterializationOnAssign() throws Exception {
runTest("js/js.translator/testData/box/coercion/unitMaterializationOnAssign.kt");
}
@Test
@TestMetadata("unitMaterializationOnCall.kt")
public void testUnitMaterializationOnCall() throws Exception {
runTest("js/js.translator/testData/box/coercion/unitMaterializationOnCall.kt");
}
@Test
@TestMetadata("unitNullCheck.kt")
public void testUnitNullCheck() throws Exception {
@@ -5742,6 +5754,12 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
runTest("js/js.translator/testData/box/inlineEvaluationOrder/propertyAccessAndInitializer.kt");
}
@Test
@TestMetadata("propertyAccessNoSideEffect.kt")
public void testPropertyAccessNoSideEffect() throws Exception {
runTest("js/js.translator/testData/box/inlineEvaluationOrder/propertyAccessNoSideEffect.kt");
}
@Test
@TestMetadata("propertyAccessWithSideEffect.kt")
public void testPropertyAccessWithSideEffect() throws Exception {