diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt index 875d62de1fb..74cb0ed02e8 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt @@ -127,8 +127,13 @@ private class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass targetForCommonBridges = bridge } - val signaturesToSkip = mutableSetOf(ourSignature) - signaturesToSkip.addAll(getFinalOverridden(irFunction).map { it.getJvmSignature() }) + val signaturesToSkip = + if (irFunction.origin != IrDeclarationOrigin.FAKE_OVERRIDE || irFunction.modality == Modality.ABSTRACT || targetForCommonBridges != irFunction) + mutableSetOf(ourSignature) + else + mutableSetOf() + + signaturesToSkip += getFinalOverridden(irFunction).map { it.getJvmSignature() } val firstOverridden = irFunction.overriddenInClasses().firstOrNull() val firstOverriddenSignature = firstOverridden?.getJvmSignature() diff --git a/compiler/testData/codegen/box/bridges/covariantGenericDiamond.kt b/compiler/testData/codegen/box/bridges/covariantGenericDiamond.kt new file mode 100644 index 00000000000..6d2727174cb --- /dev/null +++ b/compiler/testData/codegen/box/bridges/covariantGenericDiamond.kt @@ -0,0 +1,12 @@ +// IGNORE_BACKEND_FIR: JVM_IR +interface A { + val result: Any +} +interface B : A { + override val result: String +} + +abstract class AImpl(override val result: Self) : A +class BImpl(result: String) : AImpl(result), B + +fun box(): String = (BImpl("OK") as B).result \ No newline at end of file diff --git a/compiler/testData/codegen/box/defaultArguments/implementedByFake.kt b/compiler/testData/codegen/box/defaultArguments/implementedByFake.kt index db703a34fe5..b038c5f3434 100644 --- a/compiler/testData/codegen/box/defaultArguments/implementedByFake.kt +++ b/compiler/testData/codegen/box/defaultArguments/implementedByFake.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JVM interface I { diff --git a/compiler/testData/codegen/box/defaultArguments/implementedByFake2.kt b/compiler/testData/codegen/box/defaultArguments/implementedByFake2.kt index 255b1dc76d0..caa351f9c80 100644 --- a/compiler/testData/codegen/box/defaultArguments/implementedByFake2.kt +++ b/compiler/testData/codegen/box/defaultArguments/implementedByFake2.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JVM interface I { diff --git a/compiler/testData/codegen/box/defaultArguments/implementedByFake3.kt b/compiler/testData/codegen/box/defaultArguments/implementedByFake3.kt index 66e5ae0a0e6..967bee91dd1 100644 --- a/compiler/testData/codegen/box/defaultArguments/implementedByFake3.kt +++ b/compiler/testData/codegen/box/defaultArguments/implementedByFake3.kt @@ -1,5 +1,4 @@ // IGNORE_BACKEND_FIR: JVM_IR -// IGNORE_BACKEND: JVM_IR // IGNORE_BACKEND: JVM interface I { diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index d0d998d94f9..a7ffe312568 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -1377,6 +1377,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/bridges/complexTraitImpl.kt"); } + @TestMetadata("covariantGenericDiamond.kt") + public void testCovariantGenericDiamond() throws Exception { + runTest("compiler/testData/codegen/box/bridges/covariantGenericDiamond.kt"); + } + @TestMetadata("delegation.kt") public void testDelegation() throws Exception { runTest("compiler/testData/codegen/box/bridges/delegation.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index d0983ab9300..bd73837a4a4 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -1377,6 +1377,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/bridges/complexTraitImpl.kt"); } + @TestMetadata("covariantGenericDiamond.kt") + public void testCovariantGenericDiamond() throws Exception { + runTest("compiler/testData/codegen/box/bridges/covariantGenericDiamond.kt"); + } + @TestMetadata("delegation.kt") public void testDelegation() throws Exception { runTest("compiler/testData/codegen/box/bridges/delegation.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 7346b9480cc..cf4af520f83 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -1357,6 +1357,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/bridges/complexTraitImpl.kt"); } + @TestMetadata("covariantGenericDiamond.kt") + public void testCovariantGenericDiamond() throws Exception { + runTest("compiler/testData/codegen/box/bridges/covariantGenericDiamond.kt"); + } + @TestMetadata("delegation.kt") public void testDelegation() throws Exception { runTest("compiler/testData/codegen/box/bridges/delegation.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 7f6c6a24caa..ea1f7477fc2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -1357,6 +1357,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/bridges/complexTraitImpl.kt"); } + @TestMetadata("covariantGenericDiamond.kt") + public void testCovariantGenericDiamond() throws Exception { + runTest("compiler/testData/codegen/box/bridges/covariantGenericDiamond.kt"); + } + @TestMetadata("delegation.kt") public void testDelegation() throws Exception { runTest("compiler/testData/codegen/box/bridges/delegation.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 d6271b5a5ec..3a4ae6af46a 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 @@ -987,6 +987,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/bridges/complexTraitImpl.kt"); } + @TestMetadata("covariantGenericDiamond.kt") + public void testCovariantGenericDiamond() throws Exception { + runTest("compiler/testData/codegen/box/bridges/covariantGenericDiamond.kt"); + } + @TestMetadata("delegation.kt") public void testDelegation() throws Exception { runTest("compiler/testData/codegen/box/bridges/delegation.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 2946748b41e..3e13287a89e 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 @@ -987,6 +987,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/bridges/complexTraitImpl.kt"); } + @TestMetadata("covariantGenericDiamond.kt") + public void testCovariantGenericDiamond() throws Exception { + runTest("compiler/testData/codegen/box/bridges/covariantGenericDiamond.kt"); + } + @TestMetadata("delegation.kt") public void testDelegation() throws Exception { runTest("compiler/testData/codegen/box/bridges/delegation.kt");