fix(KT-49225): remove unnecessery boxing.

This commit is contained in:
Artem Kobzar
2021-10-21 06:38:42 +00:00
committed by Space
parent 9515011365
commit 3dbf996ec6
6 changed files with 34 additions and 1 deletions
@@ -41,7 +41,7 @@ class ExportedDefaultParameterStub(val context: JsIrBackendContext) : Declaratio
irIfThenElse(
toParameter.type,
irEqeqeq(
irGet(toParameter),
irGet(toParameter, context.irBuiltIns.anyNType),
irCall(this@ExportedDefaultParameterStub.context.intrinsics.jsUndefined)
),
defaultValue.expression,
@@ -128,6 +128,8 @@ fun IrBuilderWithScope.irGet(type: IrType, variable: IrValueSymbol) =
fun IrBuilderWithScope.irGet(variable: IrValueDeclaration) = irGet(variable.type, variable.symbol)
fun IrBuilderWithScope.irGet(variable: IrValueDeclaration, type: IrType) = irGet(type, variable.symbol)
fun IrBuilderWithScope.irSet(variable: IrValueSymbol, value: IrExpression, origin: IrStatementOrigin = IrStatementOrigin.EQ) =
IrSetValueImpl(startOffset, endOffset, context.irBuiltIns.unitType, variable, value, origin)
@@ -2110,6 +2110,11 @@ public class IrBoxJsES6TestGenerated extends AbstractIrBoxJsES6Test {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/export"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR_ES6, true);
}
@TestMetadata("defaultInlineClassConstructorParam.kt")
public void testDefaultInlineClassConstructorParam() throws Exception {
runTest("js/js.translator/testData/box/export/defaultInlineClassConstructorParam.kt");
}
@TestMetadata("exportAllFile.kt")
public void testExportAllFile() throws Exception {
runTest("js/js.translator/testData/box/export/exportAllFile.kt");
@@ -2105,6 +2105,11 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/export"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS_IR, true);
}
@TestMetadata("defaultInlineClassConstructorParam.kt")
public void testDefaultInlineClassConstructorParam() throws Exception {
runTest("js/js.translator/testData/box/export/defaultInlineClassConstructorParam.kt");
}
@TestMetadata("exportAllFile.kt")
public void testExportAllFile() throws Exception {
runTest("js/js.translator/testData/box/export/exportAllFile.kt");
@@ -1780,6 +1780,11 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/box/export"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.JS, true);
}
@TestMetadata("defaultInlineClassConstructorParam.kt")
public void testDefaultInlineClassConstructorParam() throws Exception {
runTest("js/js.translator/testData/box/export/defaultInlineClassConstructorParam.kt");
}
@TestMetadata("exportAllFile.kt")
public void testExportAllFile() throws Exception {
runTest("js/js.translator/testData/box/export/exportAllFile.kt");
@@ -0,0 +1,16 @@
// KT-49225
// RUN_PLAIN_BOX_FUNCTION
// IGNORE_BACKEND: JS
// MODULE: lib
// FILE: lib.kt
value class Koo(val koo: String = "OK")
@JsExport
class Bar(val koo: Koo = Koo())
// MODULE: main(lib)
// FILE: main.js
function box() {
return new main.Bar().koo;
}