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 3ca6422f1ae..b2113a4c963 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 @@ -44741,6 +44741,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/safeCall/kt4733.kt"); } + @Test + @TestMetadata("kt52580.kt") + public void testKt52580() throws Exception { + runTest("compiler/testData/codegen/box/safeCall/kt52580.kt"); + } + @Test @TestMetadata("primitive.kt") public void testPrimitive() throws Exception { diff --git a/compiler/testData/codegen/box/safeCall/kt52580.kt b/compiler/testData/codegen/box/safeCall/kt52580.kt new file mode 100644 index 00000000000..a88633f5119 --- /dev/null +++ b/compiler/testData/codegen/box/safeCall/kt52580.kt @@ -0,0 +1,32 @@ +// ISSUE: KT-52580 + +interface Base { + val a: String +} + +interface Derived : Base { + override val a: String + val b: Int +} + +class BaseImpl(override val a: String) : Base + +fun test(base: Base): String { + return consume( + base.run { a }, + (base as? Derived)?.b?.toString(), + base.a + ) +} + +fun consume(s1: String, s2: String?, s3: String): String { + return "$s1|$s2|$s3" +} + +fun box(): String { + val result = test(BaseImpl("Base")) + return when (result) { + "Base|null|Base" -> "OK" + else -> "Fail: $result" + } +} 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 33b324724e4..1a26ce0589b 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 @@ -44171,6 +44171,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/safeCall/kt4733.kt"); } + @Test + @TestMetadata("kt52580.kt") + public void testKt52580() throws Exception { + runTest("compiler/testData/codegen/box/safeCall/kt52580.kt"); + } + @Test @TestMetadata("primitive.kt") public void testPrimitive() 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 52d88c35f3e..ef6530063a8 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 @@ -44741,6 +44741,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/safeCall/kt4733.kt"); } + @Test + @TestMetadata("kt52580.kt") + public void testKt52580() throws Exception { + runTest("compiler/testData/codegen/box/safeCall/kt52580.kt"); + } + @Test @TestMetadata("primitive.kt") public void testPrimitive() 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 44ce08ef38b..daa85c516aa 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -35682,6 +35682,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/safeCall/kt4733.kt"); } + @TestMetadata("kt52580.kt") + public void testKt52580() throws Exception { + runTest("compiler/testData/codegen/box/safeCall/kt52580.kt"); + } + @TestMetadata("primitive.kt") public void testPrimitive() throws Exception { runTest("compiler/testData/codegen/box/safeCall/primitive.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 1d9c3c2c2ce..5c424f9f670 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -32485,6 +32485,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/safeCall/kt4733.kt"); } + @Test + @TestMetadata("kt52580.kt") + public void testKt52580() throws Exception { + runTest("compiler/testData/codegen/box/safeCall/kt52580.kt"); + } + @Test @TestMetadata("primitive.kt") public void testPrimitive() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 39cf2a36f9a..b2de8228ab8 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -32587,6 +32587,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/safeCall/kt4733.kt"); } + @Test + @TestMetadata("kt52580.kt") + public void testKt52580() throws Exception { + runTest("compiler/testData/codegen/box/safeCall/kt52580.kt"); + } + @Test @TestMetadata("primitive.kt") public void testPrimitive() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java index 78a5e816344..9753389341f 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/wasm/semantics/IrCodegenBoxWasmTestGenerated.java @@ -29156,6 +29156,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest runTest("compiler/testData/codegen/box/safeCall/kt4733.kt"); } + @TestMetadata("kt52580.kt") + public void testKt52580() throws Exception { + runTest("compiler/testData/codegen/box/safeCall/kt52580.kt"); + } + @TestMetadata("primitive.kt") public void testPrimitive() throws Exception { runTest("compiler/testData/codegen/box/safeCall/primitive.kt"); diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 7538ced8f67..031bee482e6 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -35580,6 +35580,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest runTest("compiler/testData/codegen/box/safeCall/kt4733.kt"); } + @Test + @TestMetadata("kt52580.kt") + public void testKt52580() throws Exception { + runTest("compiler/testData/codegen/box/safeCall/kt52580.kt"); + } + @Test @TestMetadata("primitive.kt") public void testPrimitive() throws Exception {