From c55ddab1bfaf4dfec3f5ee8ebf0581b026b763c9 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 2 Jun 2023 10:59:39 +0300 Subject: [PATCH] [Test] Reproduce KT-58823 --- ...LightTreeBlackBoxCodegenTestGenerated.java | 6 +++++ .../FirPsiBlackBoxCodegenTestGenerated.java | 6 +++++ .../smartcastOnImplicitDispatchReceiver.kt | 23 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 6 +++++ .../IrBlackBoxCodegenTestGenerated.java | 6 +++++ ...kBoxCodegenWithIrInlinerTestGenerated.java | 6 +++++ .../LightAnalysisModeTestGenerated.java | 5 ++++ 7 files changed, 58 insertions(+) create mode 100644 compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index d28c92890d1..39be017b90d 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -49543,6 +49543,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") + public void testSmartcastOnImplicitDispatchReceiver() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt"); + } + @Test @TestMetadata("toStringOnReceiverWIthSmartcast.kt") public void testToStringOnReceiverWIthSmartcast() throws Exception { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index d7840142a81..dba248ea920 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -49543,6 +49543,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") + public void testSmartcastOnImplicitDispatchReceiver() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt"); + } + @Test @TestMetadata("toStringOnReceiverWIthSmartcast.kt") public void testToStringOnReceiverWIthSmartcast() throws Exception { diff --git a/compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt b/compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt new file mode 100644 index 00000000000..90e60170b31 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt @@ -0,0 +1,23 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND_K2: JVM_IR +// ISSUE: KT-58823 +// FILE: Base.java + +public abstract class Base {} + +// FILE: Derived.java +public class Derived extends Base { + T getResult() { + return (T) "OK"; + } +} + +// FILE: main.kt +fun Base.box(): String { + return when (this) { + is Derived -> getResult() + else -> "Fail" + } +} + +fun box(): String = Derived().box() diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 698ca76d6cb..01b2397918b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -46843,6 +46843,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") + public void testSmartcastOnImplicitDispatchReceiver() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt"); + } + @Test @TestMetadata("whenSmartCast.kt") public void testWhenSmartCast() throws Exception { 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 93a03efe883..303d9f448c0 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 @@ -49543,6 +49543,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") + public void testSmartcastOnImplicitDispatchReceiver() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt"); + } + @Test @TestMetadata("toStringOnReceiverWIthSmartcast.kt") public void testToStringOnReceiverWIthSmartcast() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index c595c0884c4..04c3bd9d080 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -49543,6 +49543,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @Test + @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") + public void testSmartcastOnImplicitDispatchReceiver() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt"); + } + @Test @TestMetadata("toStringOnReceiverWIthSmartcast.kt") public void testToStringOnReceiverWIthSmartcast() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index be54e93f3f4..9b9adafbb24 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -37986,6 +37986,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/smartCasts/smartCastInsideIf.kt"); } + @TestMetadata("smartcastOnImplicitDispatchReceiver.kt") + public void testSmartcastOnImplicitDispatchReceiver() throws Exception { + runTest("compiler/testData/codegen/box/smartCasts/smartcastOnImplicitDispatchReceiver.kt"); + } + @TestMetadata("whenSmartCast.kt") public void testWhenSmartCast() throws Exception { runTest("compiler/testData/codegen/box/smartCasts/whenSmartCast.kt");