diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt index 3c947045113..4d8e24d6ef3 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt @@ -65,9 +65,9 @@ interface IrDeclarationOrigin { object FIELD_FOR_ENUM_VALUES : IrDeclarationOriginImpl("FIELD_FOR_ENUM_VALUES", isSynthetic = true) object FIELD_FOR_OBJECT_INSTANCE : IrDeclarationOriginImpl("FIELD_FOR_OBJECT_INSTANCE") - object ADAPTER_FOR_CALLABLE_REFERENCE : IrDeclarationOriginImpl("ADAPTER_FOR_CALLABLE_REFERENCE") + object ADAPTER_FOR_CALLABLE_REFERENCE : IrDeclarationOriginImpl("ADAPTER_FOR_CALLABLE_REFERENCE", isSynthetic = true) object ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE : IrDeclarationOriginImpl("ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE") - object ADAPTER_FOR_SUSPEND_CONVERSION : IrDeclarationOriginImpl("ADAPTER_FOR_SUSPEND_CONVERSION") + object ADAPTER_FOR_SUSPEND_CONVERSION : IrDeclarationOriginImpl("ADAPTER_FOR_SUSPEND_CONVERSION", isSynthetic = true) object ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION : IrDeclarationOriginImpl("ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION") object GENERATED_SAM_IMPLEMENTATION : IrDeclarationOriginImpl("GENERATED_SAM_IMPLEMENTATION") diff --git a/compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference.kt b/compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference.kt new file mode 100644 index 00000000000..c51e74e5697 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference.kt @@ -0,0 +1,11 @@ +class A { + private fun defaultArgs(value: Int = 0, message: String = "hello"): String = message + + private fun myApply(f: () -> String) {} + private fun myApplySuspend(f: suspend () -> String) {} + + fun testDefaultArguments() { + myApply(::defaultArgs) + myApplySuspend(::defaultArgs) + } +} diff --git a/compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference.txt b/compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference.txt new file mode 100644 index 00000000000..aec4b0573d3 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference.txt @@ -0,0 +1,31 @@ +@kotlin.Metadata +synthetic final class A$testDefaultArguments$1 { + // source: 'adaptedReference.kt' + enclosing method A.testDefaultArguments()V + inner (anonymous) class A$testDefaultArguments$1 + method (p0: A): void + public synthetic bridge method invoke(): java.lang.Object + public final @org.jetbrains.annotations.NotNull method invoke(): java.lang.String +} + +@kotlin.Metadata +synthetic final class A$testDefaultArguments$2 { + // source: 'adaptedReference.kt' + enclosing method A.testDefaultArguments()V + inner (anonymous) class A$testDefaultArguments$2 + method (p0: A): void + public final @org.jetbrains.annotations.Nullable method invoke(@org.jetbrains.annotations.Nullable p0: java.lang.Object): java.lang.Object +} + +@kotlin.Metadata +public final class A { + // source: 'adaptedReference.kt' + inner (anonymous) class A$testDefaultArguments$1 + inner (anonymous) class A$testDefaultArguments$2 + public method (): void + synthetic static method defaultArgs$default(p0: A, p1: int, p2: java.lang.String, p3: int, p4: java.lang.Object): java.lang.String + private final method defaultArgs(p0: int, p1: java.lang.String): java.lang.String + private final method myApply(p0: kotlin.jvm.functions.Function0): void + private final method myApplySuspend(p0: kotlin.jvm.functions.Function1): void + public final method testDefaultArguments(): void +} diff --git a/compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference_ir.txt b/compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference_ir.txt new file mode 100644 index 00000000000..b69c25f5183 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference_ir.txt @@ -0,0 +1,38 @@ +@kotlin.Metadata +synthetic final class A$testDefaultArguments$1 { + // source: 'adaptedReference.kt' + enclosing method A.testDefaultArguments()V + inner (anonymous) class A$testDefaultArguments$1 + method (p0: A): void + public synthetic final static method access$getReceiver$p(p0: A$testDefaultArguments$1): java.lang.Object + public synthetic bridge method invoke(): java.lang.Object + public final @org.jetbrains.annotations.NotNull method invoke(): java.lang.String +} + +@kotlin.Metadata +synthetic final class A$testDefaultArguments$2 { + // source: 'adaptedReference.kt' + enclosing method A.testDefaultArguments()V + inner (anonymous) class A$testDefaultArguments$2 + method (p0: A): void + public synthetic final static method access$getReceiver$p(p0: A$testDefaultArguments$2): java.lang.Object + public final @org.jetbrains.annotations.Nullable method invoke(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): java.lang.Object + public synthetic bridge method invoke(p0: java.lang.Object): java.lang.Object +} + +@kotlin.Metadata +public final class A { + // source: 'adaptedReference.kt' + inner (anonymous) class A$testDefaultArguments$1 + inner (anonymous) class A$testDefaultArguments$2 + public method (): void + public synthetic final static method access$testDefaultArguments$defaultArgs(p0: A): java.lang.String + public synthetic final static method access$testDefaultArguments$defaultArgs-0(p0: A, p1: kotlin.coroutines.Continuation): java.lang.Object + synthetic static method defaultArgs$default(p0: A, p1: int, p2: java.lang.String, p3: int, p4: java.lang.Object): java.lang.String + private final method defaultArgs(p0: int, p1: java.lang.String): java.lang.String + private final method myApply(p0: kotlin.jvm.functions.Function0): void + private final method myApplySuspend(p0: kotlin.jvm.functions.Function1): void + private synthetic final static method testDefaultArguments$defaultArgs(p0: A): java.lang.String + private synthetic final static method testDefaultArguments$defaultArgs-0(p0: A, p1: kotlin.coroutines.Continuation): java.lang.Object + public final method testDefaultArguments(): void +} diff --git a/compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion.kt b/compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion.kt new file mode 100644 index 00000000000..d168d99491e --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion.kt @@ -0,0 +1,7 @@ +// !LANGUAGE: +SuspendConversion + +fun myApply(f: suspend () -> Unit) {} + +fun test(f: () -> Unit) { + myApply(f) +} diff --git a/compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion.txt b/compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion.txt new file mode 100644 index 00000000000..cdaab6f916f --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion.txt @@ -0,0 +1,6 @@ +@kotlin.Metadata +public final class SuspendConversionKt { + // source: 'suspendConversion.kt' + public final static method myApply(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): void + public final static method test(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void +} diff --git a/compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion_ir.txt b/compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion_ir.txt new file mode 100644 index 00000000000..45ddb1bb313 --- /dev/null +++ b/compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion_ir.txt @@ -0,0 +1,19 @@ +@kotlin.Metadata +synthetic final class SuspendConversionKt$test$1 { + // source: 'suspendConversion.kt' + enclosing method SuspendConversionKt.test(Lkotlin/jvm/functions/Function0;)V + inner (anonymous) class SuspendConversionKt$test$1 + method (p0: kotlin.jvm.functions.Function0): void + public final @org.jetbrains.annotations.Nullable method invoke(@org.jetbrains.annotations.NotNull p0: kotlin.coroutines.Continuation): java.lang.Object + public synthetic bridge method invoke(p0: java.lang.Object): java.lang.Object +} + +@kotlin.Metadata +public final class SuspendConversionKt { + // source: 'suspendConversion.kt' + inner (anonymous) class SuspendConversionKt$test$1 + public synthetic final static method access$test$suspendConversion0(p0: kotlin.jvm.functions.Function0, p1: kotlin.coroutines.Continuation): java.lang.Object + public final static method myApply(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function1): void + private synthetic final static method test$suspendConversion0(p0: kotlin.jvm.functions.Function0, p1: kotlin.coroutines.Continuation): java.lang.Object + public final static method test(@org.jetbrains.annotations.NotNull p0: kotlin.jvm.functions.Function0): void +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeListingTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeListingTestGenerated.java index a822d62292a..e6486416f58 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeListingTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BytecodeListingTestGenerated.java @@ -407,6 +407,22 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/bytecodeListing/callableReference") + @TestDataPath("$PROJECT_ROOT") + public class CallableReference { + @Test + @TestMetadata("adaptedReference.kt") + public void testAdaptedReference() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference.kt"); + } + + @Test + public void testAllFilesPresentInCallableReference() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/bytecodeListing/collectionStubs") @TestDataPath("$PROJECT_ROOT") @@ -860,6 +876,12 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest { runTest("compiler/testData/codegen/bytecodeListing/coroutines/privateSuspendFun.kt"); } + @Test + @TestMetadata("suspendConversion.kt") + public void testSuspendConversion() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion.kt"); + } + @Test @TestMetadata("suspendImpl.kt") public void testSuspendImpl() throws Exception { 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 94397da4f78..c9b67a1a73c 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 @@ -407,6 +407,22 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes } } + @Nested + @TestMetadata("compiler/testData/codegen/bytecodeListing/callableReference") + @TestDataPath("$PROJECT_ROOT") + public class CallableReference { + @Test + @TestMetadata("adaptedReference.kt") + public void testAdaptedReference() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/callableReference/adaptedReference.kt"); + } + + @Test + public void testAllFilesPresentInCallableReference() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + } + @Nested @TestMetadata("compiler/testData/codegen/bytecodeListing/collectionStubs") @TestDataPath("$PROJECT_ROOT") @@ -860,6 +876,12 @@ public class IrBytecodeListingTestGenerated extends AbstractIrBytecodeListingTes runTest("compiler/testData/codegen/bytecodeListing/coroutines/privateSuspendFun.kt"); } + @Test + @TestMetadata("suspendConversion.kt") + public void testSuspendConversion() throws Exception { + runTest("compiler/testData/codegen/bytecodeListing/coroutines/suspendConversion.kt"); + } + @Test @TestMetadata("suspendImpl.kt") public void testSuspendImpl() throws Exception {