From 984493fe8baff0894d3a6c79c678594f0fb844b1 Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Fri, 15 Dec 2023 10:34:27 +0100 Subject: [PATCH] [Tests] Add regression test for #KT-62865 --- ...LightTreeBytecodeListingTestGenerated.java | 6 +++++ .../FirPsiBytecodeListingTestGenerated.java | 6 +++++ .../sam/samWithContravariantProjection.kt | 18 +++++++++++++ .../sam/samWithContravariantProjection.txt | 27 +++++++++++++++++++ .../IrBytecodeListingTestGenerated.java | 6 +++++ 5 files changed, 63 insertions(+) create mode 100644 compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.kt create mode 100644 compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.txt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBytecodeListingTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBytecodeListingTestGenerated.java index b6a67b9c1d4..8fc9ba7be2b 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBytecodeListingTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBytecodeListingTestGenerated.java @@ -2282,6 +2282,12 @@ public class FirLightTreeBytecodeListingTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/bytecodeListing/sam/samAdapterInInlineLambda.kt"); } + @Test + @TestMetadata("samWithContravariantProjection.kt") + public void testSamWithContravariantProjection() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.kt"); + } + @Test @TestMetadata("severalProxyFunsInInit.kt") public void testSeveralProxyFunsInInit() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBytecodeListingTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBytecodeListingTestGenerated.java index 57f95301025..69ab479e5a5 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBytecodeListingTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBytecodeListingTestGenerated.java @@ -2282,6 +2282,12 @@ public class FirPsiBytecodeListingTestGenerated extends AbstractFirPsiBytecodeLi runTest("compiler/testData/codegen/bytecodeListing/sam/samAdapterInInlineLambda.kt"); } + @Test + @TestMetadata("samWithContravariantProjection.kt") + public void testSamWithContravariantProjection() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.kt"); + } + @Test @TestMetadata("severalProxyFunsInInit.kt") public void testSeveralProxyFunsInInit() throws Exception { diff --git a/compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.kt b/compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.kt new file mode 100644 index 00000000000..2fd677f828e --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.kt @@ -0,0 +1,18 @@ +// FULL_JDK +// ISSUE: KT-62865 +// FILE: test.kt +import java.util.function.Consumer + +fun foo(x: Any) {} + +class A { + fun doOnSuccess(consumer: Consumer) { + } +} + +fun example() { + val instance = A() + instance.doOnSuccess(::foo) +} + + diff --git a/compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.txt b/compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.txt new file mode 100644 index 00000000000..47ff6d0cd6a --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.txt @@ -0,0 +1,27 @@ +@kotlin.Metadata +public final class A { + // source: 'test.kt' + public method (): void + public final method doOnSuccess(@org.jetbrains.annotations.NotNull p0: java.util.function.Consumer): void +} + +@kotlin.Metadata +synthetic final class TestKt$example$1 { + // source: 'test.kt' + enclosing method TestKt.example()V + public final static field INSTANCE: TestKt$example$1 + inner (anonymous) class TestKt$example$1 + static method (): void + method (): void + public synthetic bridge method invoke(p0: java.lang.Object): java.lang.Object + public final method invoke(p0: java.lang.Object): void +} + +@kotlin.Metadata +public final class TestKt { + // source: 'test.kt' + inner (anonymous) class TestKt$example$1 + private final static method example$lambda$0(p0: kotlin.jvm.functions.Function1, p1: java.lang.Object): void + public final static method example(): void + public final static method foo(@org.jetbrains.annotations.NotNull p0: java.lang.Object): void +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeListingTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeListingTestGenerated.java index ff14ce9fc08..432d2408e19 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeListingTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBytecodeListingTestGenerated.java @@ -2282,6 +2282,12 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/sam/samAdapterInInlineLambda.kt"); } + @Test + @TestMetadata("samWithContravariantProjection.kt") + public void testSamWithContravariantProjection() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/sam/samWithContravariantProjection.kt"); + } + @Test @TestMetadata("severalProxyFunsInInit.kt") public void testSeveralProxyFunsInInit() throws Exception {