From 1b8a60b5a5e2844fa526ff5ea69a8704cddb43ff Mon Sep 17 00:00:00 2001 From: Pavel Mikhailovskii Date: Mon, 26 Sep 2022 21:30:56 +0200 Subject: [PATCH] KT-51282 Add tests --- .../FirBlackBoxCodegenTestGenerated.java | 12 ++++++ .../codegen/box/invokedynamic/sam/kt51282.kt | 40 ++++++++++++++++++ .../sam/kt512832_inherit_multifile_parts.kt | 41 +++++++++++++++++++ .../IrBlackBoxCodegenTestGenerated.java | 12 ++++++ 4 files changed, 105 insertions(+) create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt create mode 100644 compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 1a1ad737eef..4d7f9be54ad 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -26792,6 +26792,18 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/invokedynamic/sam/kt47510.kt"); } + @Test + @TestMetadata("kt51282.kt") + public void testKt51282() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt"); + } + + @Test + @TestMetadata("kt512832_inherit_multifile_parts.kt") + public void testKt512832_inherit_multifile_parts() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt"); + } + @Test @TestMetadata("kt51868_contravariantGenericSam.kt") public void testKt51868_contravariantGenericSam() throws Exception { diff --git a/compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt b/compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt new file mode 100644 index 00000000000..39ccc2f9755 --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt @@ -0,0 +1,40 @@ +// SAM_CONVERSIONS: INDY +// TARGET_BACKEND: JVM_IR +// JVM_TARGET: 1.8 +// WITH_STDLIB + +// FILE: Foo.java +package org.example.foo; +public interface Foo { + String foo(String s); +} + +// FILE: bar1.kt + +@file:JvmMultifileClass +@file:JvmName("Bar") + +package org.example.bar + +fun doFoo(s: String): String = s.toUpperCase() + +// FILE: bar2.kt + +@file:JvmMultifileClass +@file:JvmName("Bar") + +package org.example.bar + +val unused = 1 + +// FILE: Baz.kt + +package org.example.baz + +import org.example.foo.Foo +import org.example.bar.doFoo + +fun box(): String { + val foo = Foo(::doFoo) + return foo.foo("ok") +} \ No newline at end of file diff --git a/compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt b/compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt new file mode 100644 index 00000000000..85d7232271d --- /dev/null +++ b/compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt @@ -0,0 +1,41 @@ +// INHERIT_MULTIFILE_PARTS +// SAM_CONVERSIONS: INDY +// TARGET_BACKEND: JVM_IR +// JVM_TARGET: 1.8 +// WITH_STDLIB + +// FILE: Foo.java +package org.example.foo; +public interface Foo { + String foo(String s); +} + +// FILE: bar1.kt + +@file:JvmMultifileClass +@file:JvmName("Bar") + +package org.example.bar + +fun doFoo(s: String): String = s.toUpperCase() + +// FILE: bar2.kt + +@file:JvmMultifileClass +@file:JvmName("Bar") + +package org.example.bar + +const val unused = 1 + +// FILE: Baz.kt + +package org.example.baz + +import org.example.foo.Foo +import org.example.bar.doFoo + +fun box(): String { + val foo = Foo(::doFoo) + return foo.foo("ok") +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index a3e1fff4ec8..37982276bc6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -26792,6 +26792,18 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/invokedynamic/sam/kt47510.kt"); } + @Test + @TestMetadata("kt51282.kt") + public void testKt51282() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/kt51282.kt"); + } + + @Test + @TestMetadata("kt512832_inherit_multifile_parts.kt") + public void testKt512832_inherit_multifile_parts() throws Exception { + runTest("compiler/testData/codegen/box/invokedynamic/sam/kt512832_inherit_multifile_parts.kt"); + } + @Test @TestMetadata("kt51868_contravariantGenericSam.kt") public void testKt51868_contravariantGenericSam() throws Exception {