diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt index 05f73e148b2..6b806fc98c5 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ExportedDefaultParameterStub.kt @@ -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, diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt index 9aaa04fec29..54d3fa46e3e 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt @@ -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) diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java index 0a857d33796..23620275cfd 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrBoxJsES6TestGenerated.java @@ -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"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java index fc3201d06d2..5fe6b97128d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrBoxJsTestGenerated.java @@ -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"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java index a8f77ac27ee..91348071ba6 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/BoxJsTestGenerated.java @@ -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"); diff --git a/js/js.translator/testData/box/export/defaultInlineClassConstructorParam.kt b/js/js.translator/testData/box/export/defaultInlineClassConstructorParam.kt new file mode 100644 index 00000000000..eba7dfed5ff --- /dev/null +++ b/js/js.translator/testData/box/export/defaultInlineClassConstructorParam.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; +} \ No newline at end of file