From 64d40aa285121ad31fdb9f21f2381dd655564044 Mon Sep 17 00:00:00 2001 From: "xiaozihan.larryxiao" Date: Sun, 11 Dec 2022 01:57:18 +0800 Subject: [PATCH] KT-55398 Add test case Add KT-55398 test case into boxInline/reified --- .../codegen/boxInline/reified/kt55398.kt | 47 +++++++++++++++++++ .../BlackBoxInlineCodegenTestGenerated.java | 6 +++ ...otlinAgainstInlineKotlinTestGenerated.java | 6 +++ .../IrBlackBoxInlineCodegenTestGenerated.java | 6 +++ ...otlinAgainstInlineKotlinTestGenerated.java | 6 +++ 5 files changed, 71 insertions(+) create mode 100644 compiler/testData/codegen/boxInline/reified/kt55398.kt diff --git a/compiler/testData/codegen/boxInline/reified/kt55398.kt b/compiler/testData/codegen/boxInline/reified/kt55398.kt new file mode 100644 index 00000000000..3b1ce469325 --- /dev/null +++ b/compiler/testData/codegen/boxInline/reified/kt55398.kt @@ -0,0 +1,47 @@ +// TARGET_BACKEND: JVM +// WITH_STDLIB +// FULL_JDK +// FILE: 1.kt +package test + +import kotlin.properties.ReadOnlyProperty +import kotlin.reflect.KProperty +interface Base { +} + +class BaseImpl : Base { +} + +class ObjectContainer { +} + +typealias ObjectContainerProvider = () -> ObjectContainer? + +internal inline fun ObjectContainerProvider.extensionFun(): ReadOnlyProperty { + + return object : ReadOnlyProperty { + val emptyProxy: T by lazy { + T::class.java.getDeclaredConstructor().newInstance() + } + + override fun getValue(thisRef: Any, property: KProperty<*>): T = emptyProxy + } + +} + +// FILE: 2.kt +import test.* + +class DefaultObjectContainerProvider : ObjectContainerProvider { + val baseImpl: BaseImpl by extensionFun() + + override fun invoke(): ObjectContainer? { + return null + } +} + +fun box(): String { + DefaultObjectContainerProvider().baseImpl + + return "OK" +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java index b7eae318a03..bf6c909b0ca 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -4062,6 +4062,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/reified/singletonLambda.kt"); } + @Test + @TestMetadata("kt55398.kt") + public void testKt55398() throws Exception { + runTest("compiler/testData/codegen/boxInline/reified/kt55398.kt"); + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/reified/checkCast") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index d01910ced22..8ea24fc1fab 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4062,6 +4062,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/reified/singletonLambda.kt"); } + @Test + @TestMetadata("kt55398.kt") + public void testKt55398() throws Exception { + runTest("compiler/testData/codegen/boxInline/reified/kt55398.kt"); + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/reified/checkCast") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java index d7831438759..c00caaf89ca 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java @@ -4086,6 +4086,12 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/reified/singletonLambda.kt"); } + @Test + @TestMetadata("kt55398.kt") + public void testKt55398() throws Exception { + runTest("compiler/testData/codegen/boxInline/reified/kt55398.kt"); + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/reified/checkCast") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 02defb380dc..93a0db8a5c0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4086,6 +4086,12 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/reified/singletonLambda.kt"); } + @Test + @TestMetadata("kt55398.kt") + public void testKt55398() throws Exception { + runTest("compiler/testData/codegen/boxInline/reified/kt55398.kt"); + } + @Nested @TestMetadata("compiler/testData/codegen/boxInline/reified/checkCast") @TestDataPath("$PROJECT_ROOT")