From a53ad098d60c90922a6044d4e1f84c7403a16d77 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 25 Nov 2015 15:00:58 +0300 Subject: [PATCH] Codegen test for smart cast to Nothing? --- compiler/testData/codegen/box/smartCasts/nullSmartCast.kt | 8 ++++++++ .../codegen/generated/BlackBoxCodegenTestGenerated.java | 6 ++++++ 2 files changed, 14 insertions(+) create mode 100644 compiler/testData/codegen/box/smartCasts/nullSmartCast.kt diff --git a/compiler/testData/codegen/box/smartCasts/nullSmartCast.kt b/compiler/testData/codegen/box/smartCasts/nullSmartCast.kt new file mode 100644 index 00000000000..1b74cbd9ea3 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/nullSmartCast.kt @@ -0,0 +1,8 @@ +fun String?.foo() = this ?: "OK" + +fun foo(i: Int?): String { + if (i == null) return i.foo() + return "$i" +} + +fun box() = foo(null) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index eab04c32b67..5ccde502500 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -7305,6 +7305,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/smartCasts/implicitToGrandSon.kt"); doTest(fileName); } + + @TestMetadata("nullSmartCast.kt") + public void testNullSmartCast() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/smartCasts/nullSmartCast.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/codegen/box/specialBuiltins")