diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java index 697c25f4c10..309484d4b6b 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/ir/Fir2IrTextTestGenerated.java @@ -244,6 +244,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/classes/kt45853.kt"); } + @Test + @TestMetadata("kt45934.kt") + public void testKt45934() throws Exception { + runTest("compiler/testData/ir/irText/classes/kt45934.kt"); + } + @Test @TestMetadata("lambdaInDataClassDefaultParameter.kt") public void testLambdaInDataClassDefaultParameter() throws Exception { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/SyntheticDeclarationsGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/SyntheticDeclarationsGenerator.kt index d5541b847d7..3a0de96b15a 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/SyntheticDeclarationsGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/SyntheticDeclarationsGenerator.kt @@ -56,7 +56,9 @@ class SyntheticDeclarationsGenerator(context: GeneratorContext) : DeclarationDes override fun visitFunctionDescriptor(descriptor: FunctionDescriptor, data: IrDeclarationContainer?) { require(data != null) - if (descriptor.visibility != DescriptorVisibilities.INVISIBLE_FAKE) { + if (descriptor.visibility != DescriptorVisibilities.INVISIBLE_FAKE && + descriptor.kind != CallableMemberDescriptor.Kind.DELEGATION // Skip mismatching delegates, see KT-46120 + ) { symbolTable.declareSimpleFunctionIfNotExists(descriptor) { createFunctionStub(descriptor, it).insertDeclaration(data) } diff --git a/compiler/testData/codegen/bytecodeListing/kt45934.kt b/compiler/testData/codegen/bytecodeListing/kt45934.kt new file mode 100644 index 00000000000..f9496acabb8 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/kt45934.kt @@ -0,0 +1,22 @@ +// FILE: kt45934.kt + +class C(client: J) : I by client + +// FILE: I.java + +import java.util.List; + +public interface I { + List foo(); +} + +// FILE: J.java + +import java.util.List; + +public class J implements I { + @Override + public List foo() { + return null; + } +} diff --git a/compiler/testData/codegen/bytecodeListing/kt45934.txt b/compiler/testData/codegen/bytecodeListing/kt45934.txt new file mode 100644 index 00000000000..51aaa05486c --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/kt45934.txt @@ -0,0 +1,6 @@ +@kotlin.Metadata +public final class C { + // source: 'kt45934.kt' + private synthetic final field $$delegate_0: J + public method (@org.jetbrains.annotations.NotNull p0: J): void +} diff --git a/compiler/testData/ir/irText/classes/kt45934.fir.txt b/compiler/testData/ir/irText/classes/kt45934.fir.txt new file mode 100644 index 00000000000..595be85c87a --- /dev/null +++ b/compiler/testData/ir/irText/classes/kt45934.fir.txt @@ -0,0 +1,35 @@ +FILE fqName: fileName:/kt45934.kt + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.I] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> (client:.J) returnType:.C [primary] + VALUE_PARAMETER name:client index:0 type:.J + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.I]' + FUN DELEGATED_MEMBER name:foo visibility:public modality:OPEN ($this:.C) returnType:@[FlexibleNullability] kotlin.collections.List<@[FlexibleNullability] C of .C.foo?>? + overridden: + public abstract fun foo (): @[FlexibleNullability] kotlin.collections.List<@[FlexibleNullability] C of .I.foo?>? declared in .I + TYPE_PARAMETER name:C index:0 variance: superTypes:[@[FlexibleNullability] kotlin.Any?] + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun foo (): @[FlexibleNullability] kotlin.collections.List<@[FlexibleNullability] C of .C.foo?>? declared in .C' + CALL 'public abstract fun foo (): @[FlexibleNullability] kotlin.collections.List<@[FlexibleNullability] C of .I.foo?>? declared in .I' type=@[FlexibleNullability] kotlin.collections.List<@[FlexibleNullability] C of .C.foo?>? origin=null + : + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.I visibility:local [final]' type=.I origin=null + receiver: GET_VAR ': .C declared in .C.foo' type=.C origin=null + FIELD DELEGATE name:<$$delegate_0> type:.I visibility:local [final] + EXPRESSION_BODY + GET_VAR 'client: .J declared in .C.' type=.J origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .I + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .I + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .I + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/testData/ir/irText/classes/kt45934.kt b/compiler/testData/ir/irText/classes/kt45934.kt new file mode 100644 index 00000000000..810b27c1202 --- /dev/null +++ b/compiler/testData/ir/irText/classes/kt45934.kt @@ -0,0 +1,24 @@ +// SKIP_KT_DUMP + +// FILE: kt45934.kt + +class C(client: J) : I by client + +// FILE: I.java + +import java.util.List; + +public interface I { + List foo(); +} + +// FILE: J.java + +import java.util.List; + +public class J implements I { + @Override + public List foo() { + return null; + } +} diff --git a/compiler/testData/ir/irText/classes/kt45934.txt b/compiler/testData/ir/irText/classes/kt45934.txt new file mode 100644 index 00000000000..158048185fa --- /dev/null +++ b/compiler/testData/ir/irText/classes/kt45934.txt @@ -0,0 +1,24 @@ +FILE fqName: fileName:/kt45934.kt + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.I] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> (client:.J) returnType:.C [primary] + VALUE_PARAMETER name:client index:0 type:.J + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.I]' + FIELD DELEGATE name:$$delegate_0 type:.J visibility:private [final] + EXPRESSION_BODY + GET_VAR 'client: .J declared in .C.' type=.J origin=null + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [fake_override,operator] declared in .I + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int [fake_override] declared in .I + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String [fake_override] declared in .I + $this: VALUE_PARAMETER name: type:kotlin.Any diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java index 1b5559bbfbf..96f6cec71da 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ir/IrTextTestGenerated.java @@ -244,6 +244,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest { runTest("compiler/testData/ir/irText/classes/kt45853.kt"); } + @Test + @TestMetadata("kt45934.kt") + public void testKt45934() throws Exception { + runTest("compiler/testData/ir/irText/classes/kt45934.kt"); + } + @Test @TestMetadata("lambdaInDataClassDefaultParameter.kt") public void testLambdaInDataClassDefaultParameter() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java index befda0b112d..ee2583a1a7a 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BytecodeListingTestGenerated.java @@ -180,6 +180,11 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/kt45853a.kt"); } + @TestMetadata("kt45934.kt") + public void testKt45934() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/kt45934.kt"); + } + @TestMetadata("localFunction.kt") public void testLocalFunction() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/localFunction.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java index 511a09af7b1..0498a1c1511 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBytecodeListingTestGenerated.java @@ -180,6 +180,11 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/kt45853a.kt"); } + @TestMetadata("kt45934.kt") + public void testKt45934() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/kt45934.kt"); + } + @TestMetadata("localFunction.kt") public void testLocalFunction() throws Exception { runTest("compiler/testData/codegen/bytecodeListing/localFunction.kt");