diff --git a/compiler/testData/codegen/box/sam/castFromAny.kt b/compiler/testData/codegen/box/sam/castFromAny.kt new file mode 100644 index 00000000000..d843ac68847 --- /dev/null +++ b/compiler/testData/codegen/box/sam/castFromAny.kt @@ -0,0 +1,14 @@ +// TARGET_BACKEND: JVM + +fun test(a: Any?) { + a as () -> Unit + Runnable(a).run() +} + +fun box(): String { + var result = "Fail" + test { + result = "OK" + } + return result +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 5010b551261..cfe6f47a6f1 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -23336,6 +23336,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/sam"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } + @TestMetadata("castFromAny.kt") + public void testCastFromAny() throws Exception { + runTest("compiler/testData/codegen/box/sam/castFromAny.kt"); + } + @TestMetadata("kt17091.kt") public void testKt17091() throws Exception { runTest("compiler/testData/codegen/box/sam/kt17091.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 2ae341cfb31..2bc5638820b 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -23336,6 +23336,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/sam"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); } + @TestMetadata("castFromAny.kt") + public void testCastFromAny() throws Exception { + runTest("compiler/testData/codegen/box/sam/castFromAny.kt"); + } + @TestMetadata("kt17091.kt") public void testKt17091() throws Exception { runTest("compiler/testData/codegen/box/sam/kt17091.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 9dcf2c3c5f7..7393235be63 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -22236,6 +22236,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/sam"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); } + @TestMetadata("castFromAny.kt") + public void testCastFromAny() throws Exception { + runTest("compiler/testData/codegen/box/sam/castFromAny.kt"); + } + @TestMetadata("kt17091.kt") public void testKt17091() throws Exception { runTest("compiler/testData/codegen/box/sam/kt17091.kt");