diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 4206bc780f7..39d85225c3e 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -14670,6 +14670,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/ir/kt29833.kt"); } + @TestMetadata("kt40083.kt") + public void testKt40083() throws Exception { + runTest("compiler/testData/codegen/box/ir/kt40083.kt"); + } + @TestMetadata("objectClass.kt") public void testObjectClass() throws Exception { runTest("compiler/testData/codegen/box/ir/objectClass.kt"); diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/overrides/FakeOverrideCopier.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/overrides/FakeOverrideCopier.kt index 769fdd2804b..4a3a74c9edb 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/overrides/FakeOverrideCopier.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/overrides/FakeOverrideCopier.kt @@ -5,14 +5,11 @@ package org.jetbrains.kotlin.backend.common.overrides -import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin -import org.jetbrains.kotlin.ir.declarations.IrFunction -import org.jetbrains.kotlin.ir.declarations.IrProperty -import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction +import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.util.* class FakeOverrideCopier( - symbolRemapper: SymbolRemapper, + private val symbolRemapper: SymbolRemapper, private val typeRemapper: TypeRemapper, private val symbolRenamer: SymbolRenamer ) : DeepCopyIrTreeWithSymbols(symbolRemapper, typeRemapper, symbolRenamer) { @@ -87,4 +84,20 @@ class FakeOverrideCopier( this.getter = declaration.getter?.transform() this.setter = declaration.setter?.transform() } + + override fun visitValueParameter(declaration: IrValueParameter): IrValueParameter = + declaration.factory.createValueParameter( + declaration.startOffset, declaration.endOffset, + mapDeclarationOrigin(declaration.origin), + symbolRemapper.getDeclaredValueParameter(declaration.symbol), + symbolRenamer.getValueParameterName(declaration.symbol), + declaration.index, + declaration.type.remapType(), + declaration.varargElementType?.remapType(), + declaration.isCrossinline, + declaration.isNoinline + ).apply { + transformAnnotations(declaration) + // Don't set the default value for fake overrides. + } } diff --git a/compiler/testData/codegen/box/ir/kt40083.kt b/compiler/testData/codegen/box/ir/kt40083.kt new file mode 100644 index 00000000000..c0df35b4ac3 --- /dev/null +++ b/compiler/testData/codegen/box/ir/kt40083.kt @@ -0,0 +1,21 @@ +// MODULE: lib +// FILE: lib.kt + +// KT-40083 + +open class X { + open fun red(x: Int, y: (() -> Int) = { 31 }): Int { + return x+y() + } +} + +class Y: X() + +// MODULE: main(lib) +// FILE: main.kt +fun box(): String { + if (Y().red(17) { 23 } != 40) return "FAIL 1" + if (Y().red(29) != 60) return "FAIL 2" + return "OK" +} + diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index e8b605c6525..43b704208e1 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -15895,6 +15895,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/ir/kt29833.kt"); } + @TestMetadata("kt40083.kt") + public void testKt40083() throws Exception { + runTest("compiler/testData/codegen/box/ir/kt40083.kt"); + } + @TestMetadata("objectClass.kt") public void testObjectClass() throws Exception { runTest("compiler/testData/codegen/box/ir/objectClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index bbefe37a56b..adbfb1c1d5b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -15895,6 +15895,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/ir/kt29833.kt"); } + @TestMetadata("kt40083.kt") + public void testKt40083() throws Exception { + runTest("compiler/testData/codegen/box/ir/kt40083.kt"); + } + @TestMetadata("objectClass.kt") public void testObjectClass() throws Exception { runTest("compiler/testData/codegen/box/ir/objectClass.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index ec7bb2bbcb0..53d01b62b64 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -14670,6 +14670,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/ir/kt29833.kt"); } + @TestMetadata("kt40083.kt") + public void testKt40083() throws Exception { + runTest("compiler/testData/codegen/box/ir/kt40083.kt"); + } + @TestMetadata("objectClass.kt") public void testObjectClass() throws Exception { runTest("compiler/testData/codegen/box/ir/objectClass.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 72712da8a61..8bec27c0f6e 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -12770,6 +12770,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/ir/kt25405.kt"); } + @TestMetadata("kt40083.kt") + public void testKt40083() throws Exception { + runTest("compiler/testData/codegen/box/ir/kt40083.kt"); + } + @TestMetadata("objectClass.kt") public void testObjectClass() throws Exception { runTest("compiler/testData/codegen/box/ir/objectClass.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 9e099e65b64..b218a530ee3 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -12770,6 +12770,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/ir/kt25405.kt"); } + @TestMetadata("kt40083.kt") + public void testKt40083() throws Exception { + runTest("compiler/testData/codegen/box/ir/kt40083.kt"); + } + @TestMetadata("objectClass.kt") public void testObjectClass() throws Exception { runTest("compiler/testData/codegen/box/ir/objectClass.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index e47cd58d521..311a975cd91 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -12835,6 +12835,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/ir/kt25405.kt"); } + @TestMetadata("kt40083.kt") + public void testKt40083() throws Exception { + runTest("compiler/testData/codegen/box/ir/kt40083.kt"); + } + @TestMetadata("objectClass.kt") public void testObjectClass() throws Exception { runTest("compiler/testData/codegen/box/ir/objectClass.kt");