diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 8fe8d29ca9d..cd8c8a3f6cd 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -15979,6 +15979,69 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inTopLevelPropertyInitializer.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullCheckOnLambdaReturnValue extends AbstractFirBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: "); + } + + public void testAllFilesPresentInNullCheckOnLambdaReturnValue() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("nnStringVsT.kt") + public void testNnStringVsT() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsT.kt"); + } + + @TestMetadata("nnStringVsTAny.kt") + public void testNnStringVsTAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTAny.kt"); + } + + @TestMetadata("nnStringVsTConstrained.kt") + public void testNnStringVsTConstrained() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTConstrained.kt"); + } + + @TestMetadata("nnStringVsTXArray.kt") + public void testNnStringVsTXArray() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXArray.kt"); + } + + @TestMetadata("nnStringVsTXString.kt") + public void testNnStringVsTXString() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXString.kt"); + } + + @TestMetadata("stringVsT.kt") + public void testStringVsT() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsT.kt"); + } + + @TestMetadata("stringVsTAny.kt") + public void testStringVsTAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTAny.kt"); + } + + @TestMetadata("stringVsTConstrained.kt") + public void testStringVsTConstrained() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTConstrained.kt"); + } + + @TestMetadata("stringVsTXArray.kt") + public void testStringVsTXArray() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXArray.kt"); + } + + @TestMetadata("stringVsTXString.kt") + public void testStringVsTXString() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXString.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/javaInterop/objectMethods") diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 35f1b713165..12d8d3f7bbc 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -2161,6 +2161,69 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { public void testPlatformTypeReceiver() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/platformTypeReceiver.kt"); } + + @TestMetadata("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullCheckOnLambdaResult extends AbstractFir2IrTextTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.ANY, testDataFilePath, "// IGNORE_BACKEND_FIR: "); + } + + public void testAllFilesPresentInNullCheckOnLambdaResult() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("nnStringVsT.kt") + public void testNnStringVsT() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.kt"); + } + + @TestMetadata("nnStringVsTAny.kt") + public void testNnStringVsTAny() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.kt"); + } + + @TestMetadata("nnStringVsTConstrained.kt") + public void testNnStringVsTConstrained() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.kt"); + } + + @TestMetadata("nnStringVsTXArray.kt") + public void testNnStringVsTXArray() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.kt"); + } + + @TestMetadata("nnStringVsTXString.kt") + public void testNnStringVsTXString() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt"); + } + + @TestMetadata("stringVsT.kt") + public void testStringVsT() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.kt"); + } + + @TestMetadata("stringVsTAny.kt") + public void testStringVsTAny() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.kt"); + } + + @TestMetadata("stringVsTConstrained.kt") + public void testStringVsTConstrained() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt"); + } + + @TestMetadata("stringVsTXArray.kt") + public void testStringVsTXArray() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.kt"); + } + + @TestMetadata("stringVsTXString.kt") + public void testStringVsTXString() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.kt"); + } + } } } } diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsT.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsT.kt new file mode 100644 index 00000000000..996466da788 --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsT.kt @@ -0,0 +1,26 @@ +// TARGET_BACKEND: JVM +// FILE: nnStringVsT.kt +fun useT(fn: () -> T) = fn() + +fun checkNull(x: Any?) { + if (x != null) throw AssertionError("null expected") +} + +fun box(): String { + checkNull(useT { J.notNullString() }) + return "OK" +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTAny.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTAny.kt new file mode 100644 index 00000000000..15e6fc82292 --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTAny.kt @@ -0,0 +1,26 @@ +// TARGET_BACKEND: JVM +// FILE: nnStringVsTAny.kt +fun useTAny(fn: () -> T) = fn() + +fun checkNull(x: Any?) { + if (x != null) throw AssertionError("null expected") +} + +fun box(): String { + checkNull(useTAny { J.notNullString() }) + return "OK" +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTConstrained.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTConstrained.kt new file mode 100644 index 00000000000..1ded9142e08 --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTConstrained.kt @@ -0,0 +1,29 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR +// FILE: nnStringVsTConstrained.kt +fun useTConstrained(xs: Array, fn: () -> T) = fn() + +fun box(): String { + val xs = Array(1) { "" } + try { + useTConstrained(xs) { J.notNullString() } + } catch (e: NullPointerException) { + return "OK" + } + throw AssertionError("NullPointerException expected") +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXArray.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXArray.kt new file mode 100644 index 00000000000..3b4f36ac96f --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXArray.kt @@ -0,0 +1,29 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR +// FILE: nnStringVsTXArray.kt +fun useTX(x: T, fn: () -> T) = fn() + +fun box(): String { + val xs = Array(1) { "" } + try { + useTX(xs) { J.notNullString() } + } catch (e: NullPointerException) { + return "OK" + } + throw AssertionError("NullPointerException expected") +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXString.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXString.kt new file mode 100644 index 00000000000..99336823c9b --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXString.kt @@ -0,0 +1,28 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR +// FILE: nnStringVsTXString.kt +fun useTX(x: T, fn: () -> T) = fn() + +fun box(): String { + try { + useTX("") { J.notNullString() } + } catch (e: NullPointerException) { + return "OK" + } + throw AssertionError("NullPointerException expected") +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsT.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsT.kt new file mode 100644 index 00000000000..8f8cb73d051 --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsT.kt @@ -0,0 +1,26 @@ +// TARGET_BACKEND: JVM +// FILE: stringVsT.kt +fun useT(fn: () -> T) = fn() + +fun checkNull(x: Any?) { + if (x != null) throw AssertionError("null expected") +} + +fun box(): String { + checkNull(useT { J.string() }) + return "OK" +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTAny.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTAny.kt new file mode 100644 index 00000000000..28b96f7f038 --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTAny.kt @@ -0,0 +1,26 @@ +// TARGET_BACKEND: JVM +// FILE: stringVsTAny.kt +fun useTAny(fn: () -> T) = fn() + +fun checkNull(x: Any?) { + if (x != null) throw AssertionError("null expected") +} + +fun box(): String { + checkNull(useTAny { J.string() }) + return "OK" +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTConstrained.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTConstrained.kt new file mode 100644 index 00000000000..f6e9bbf03be --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTConstrained.kt @@ -0,0 +1,28 @@ +// TARGET_BACKEND: JVM +// IGNORE_BACKEND_FIR: JVM_IR +// FILE: stringVsTConstrained.kt +fun useTConstrained(xs: Array, fn: () -> T) = fn() + +fun box(): String { + val xs = Array(1) { "" } + try { + useTConstrained(xs) { J.string() } + } catch (e: NullPointerException) { + return "OK" + } + throw AssertionError("NullPointerException expected") +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXArray.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXArray.kt new file mode 100644 index 00000000000..08ecdd4deca --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXArray.kt @@ -0,0 +1,27 @@ +// TARGET_BACKEND: JVM +// FILE: stringVsTXArray.kt +fun useTX(x: T, fn: () -> T) = fn() + +fun checkNull(x: Any?) { + if (x != null) throw AssertionError("null expected") +} + +fun box(): String { + val xs = Array(1) { "" } + checkNull(useTX(xs) { J.string() }) + return "OK" +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXString.kt b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXString.kt new file mode 100644 index 00000000000..dbf135cba76 --- /dev/null +++ b/compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXString.kt @@ -0,0 +1,26 @@ +// TARGET_BACKEND: JVM +// FILE: stringVsTXString.kt +fun useTX(x: T, fn: () -> T) = fn() + +fun checkNull(x: Any?) { + if (x != null) throw AssertionError("null expected") +} + +fun box(): String { + checkNull(useTX("") { J.string() }) + return "OK" +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/javaWildcardType.fir.txt b/compiler/testData/ir/irText/types/javaWildcardType.fir.txt new file mode 100644 index 00000000000..5dc5a48b9b0 --- /dev/null +++ b/compiler/testData/ir/irText/types/javaWildcardType.fir.txt @@ -0,0 +1,147 @@ +FILE fqName: fileName:/javaWildcardType.kt + CLASS INTERFACE name:K modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.K + FUN name:kf1 visibility:public modality:ABSTRACT <> ($this:.K) returnType:kotlin.collections.Collection + $this: VALUE_PARAMETER name: type:.K + FUN name:kf2 visibility:public modality:ABSTRACT <> ($this:.K) returnType:kotlin.collections.Collection + $this: VALUE_PARAMETER name: type:.K + FUN name:kg1 visibility:public modality:ABSTRACT <> ($this:.K, c:kotlin.collections.Collection) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.K + VALUE_PARAMETER name:c index:0 type:kotlin.collections.Collection + FUN name:kg2 visibility:public modality:ABSTRACT <> ($this:.K, c:kotlin.collections.Collection) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.K + VALUE_PARAMETER name:c index:0 type:kotlin.collections.Collection + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.J; .K] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.C + CONSTRUCTOR visibility:public <> (j:.J, k:.K) returnType:.C [primary] + VALUE_PARAMETER name:j index:0 type:.J + VALUE_PARAMETER name:k index:1 type:.K + BLOCK_BODY + DELEGATING_CONSTRUCTOR_CALL 'public constructor () [primary] declared in kotlin.Any' + INSTANCE_INITIALIZER_CALL classDescriptor='CLASS CLASS name:C modality:FINAL visibility:public superTypes:[.J; .K]' + SET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .C declared in .C' type=.C origin=null + value: GET_VAR 'j: .J declared in .C.' type=.J origin=null + SET_FIELD 'FIELD DELEGATE name:<$$delegate_1> type:.K visibility:local [final]' type=kotlin.Unit origin=EQ + receiver: GET_VAR ': .C declared in .C' type=.C origin=null + value: GET_VAR 'k: .K declared in .C.' type=.K origin=null + FUN DELEGATED_MEMBER name:jf1 visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.collections.Collection? + overridden: + public abstract fun jf1 (): kotlin.collections.Collection? declared in .J + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun jf1 (): kotlin.collections.Collection? declared in .C' + CALL 'public abstract fun jf1 (): kotlin.collections.Collection? declared in .J' type=kotlin.collections.Collection? origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + receiver: GET_VAR ': .C declared in .C.jf1' type=.C origin=null + FUN DELEGATED_MEMBER name:jf2 visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.collections.Collection? + overridden: + public abstract fun jf2 (): kotlin.collections.Collection? declared in .J + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun jf2 (): kotlin.collections.Collection? declared in .C' + CALL 'public abstract fun jf2 (): kotlin.collections.Collection? declared in .J' type=kotlin.collections.Collection? origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + receiver: GET_VAR ': .C declared in .C.jf2' type=.C origin=null + FUN DELEGATED_MEMBER name:jg1 visibility:public modality:OPEN <> ($this:.C, c:kotlin.collections.Collection?) returnType:kotlin.Unit + overridden: + public abstract fun jg1 (c: kotlin.collections.Collection?): kotlin.Unit declared in .J + $this: VALUE_PARAMETER name: type:.C + VALUE_PARAMETER name:c index:0 type:kotlin.collections.Collection? + BLOCK_BODY + CALL 'public abstract fun jg1 (c: kotlin.collections.Collection?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + receiver: GET_VAR ': .C declared in .C.jg1' type=.C origin=null + c: GET_VAR 'c: kotlin.collections.Collection? declared in .C.jg1' type=kotlin.collections.Collection? origin=null + FUN DELEGATED_MEMBER name:jg2 visibility:public modality:OPEN <> ($this:.C, c:kotlin.collections.Collection?) returnType:kotlin.Unit + overridden: + public abstract fun jg2 (c: kotlin.collections.Collection?): kotlin.Unit declared in .J + $this: VALUE_PARAMETER name: type:.C + VALUE_PARAMETER name:c index:0 type:kotlin.collections.Collection? + BLOCK_BODY + CALL 'public abstract fun jg2 (c: kotlin.collections.Collection?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + receiver: GET_VAR ': .C declared in .C.jg2' type=.C origin=null + c: GET_VAR 'c: kotlin.collections.Collection? declared in .C.jg2' type=kotlin.collections.Collection? origin=null + FUN DELEGATED_MEMBER name:equals visibility:public modality:OPEN <> ($this:.C, other:kotlin.Any?) returnType:kotlin.Boolean [operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any + $this: VALUE_PARAMETER name: type:.C + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in .C' + CALL 'public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any' type=kotlin.Boolean origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + receiver: GET_VAR ': .C declared in .C.equals' type=.C origin=null + other: GET_VAR 'other: kotlin.Any? declared in .C.equals' type=kotlin.Any? origin=null + FUN DELEGATED_MEMBER name:hashCode visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.Int + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun hashCode (): kotlin.Int declared in .C' + CALL 'public open fun hashCode (): kotlin.Int declared in kotlin.Any' type=kotlin.Int origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + receiver: GET_VAR ': .C declared in .C.hashCode' type=.C origin=null + FUN DELEGATED_MEMBER name:toString visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.String + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun toString (): kotlin.String declared in .C' + CALL 'public open fun toString (): kotlin.String declared in kotlin.Any' type=kotlin.String origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final]' type=.J origin=null + receiver: GET_VAR ': .C declared in .C.toString' type=.C origin=null + FIELD DELEGATE name:<$$delegate_0> type:.J visibility:local [final] + FUN DELEGATED_MEMBER name:kf1 visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.collections.Collection + overridden: + public abstract fun kf1 (): kotlin.collections.Collection declared in .K + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun kf1 (): kotlin.collections.Collection declared in .C' + CALL 'public abstract fun kf1 (): kotlin.collections.Collection declared in .K' type=kotlin.collections.Collection origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_1> type:.K visibility:local [final]' type=.K origin=null + receiver: GET_VAR ': .C declared in .C.kf1' type=.C origin=null + FUN DELEGATED_MEMBER name:kf2 visibility:public modality:OPEN <> ($this:.C) returnType:kotlin.collections.Collection + overridden: + public abstract fun kf2 (): kotlin.collections.Collection declared in .K + $this: VALUE_PARAMETER name: type:.C + BLOCK_BODY + RETURN type=kotlin.Nothing from='public open fun kf2 (): kotlin.collections.Collection declared in .C' + CALL 'public abstract fun kf2 (): kotlin.collections.Collection declared in .K' type=kotlin.collections.Collection origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_1> type:.K visibility:local [final]' type=.K origin=null + receiver: GET_VAR ': .C declared in .C.kf2' type=.C origin=null + FUN DELEGATED_MEMBER name:kg1 visibility:public modality:OPEN <> ($this:.C, c:kotlin.collections.Collection) returnType:kotlin.Unit + overridden: + public abstract fun kg1 (c: kotlin.collections.Collection): kotlin.Unit declared in .K + $this: VALUE_PARAMETER name: type:.C + VALUE_PARAMETER name:c index:0 type:kotlin.collections.Collection + BLOCK_BODY + CALL 'public abstract fun kg1 (c: kotlin.collections.Collection): kotlin.Unit declared in .K' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_1> type:.K visibility:local [final]' type=.K origin=null + receiver: GET_VAR ': .C declared in .C.kg1' type=.C origin=null + c: GET_VAR 'c: kotlin.collections.Collection declared in .C.kg1' type=kotlin.collections.Collection origin=null + FUN DELEGATED_MEMBER name:kg2 visibility:public modality:OPEN <> ($this:.C, c:kotlin.collections.Collection) returnType:kotlin.Unit + overridden: + public abstract fun kg2 (c: kotlin.collections.Collection): kotlin.Unit declared in .K + $this: VALUE_PARAMETER name: type:.C + VALUE_PARAMETER name:c index:0 type:kotlin.collections.Collection + BLOCK_BODY + CALL 'public abstract fun kg2 (c: kotlin.collections.Collection): kotlin.Unit declared in .K' type=kotlin.Unit origin=null + $this: GET_FIELD 'FIELD DELEGATE name:<$$delegate_1> type:.K visibility:local [final]' type=.K origin=null + receiver: GET_VAR ': .C declared in .C.kg2' type=.C origin=null + c: GET_VAR 'c: kotlin.collections.Collection declared in .C.kg2' type=kotlin.collections.Collection origin=null + FIELD DELEGATE name:<$$delegate_1> type:.K visibility:local [final] diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.fir.txt new file mode 100644 index 00000000000..1e80292868e --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.fir.txt @@ -0,0 +1,18 @@ +FILE fqName: fileName:/nnStringVsT.kt + FUN name:useT visibility:public modality:FINAL (fn:kotlin.Function0.useT>) returnType:T of .useT + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.useT> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useT (fn: kotlin.Function0.useT>): T of .useT declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useT origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useT> declared in .useT' type=kotlin.Function0.useT> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useT (fn: kotlin.Function0.useT>): T of .useT declared in ' type=kotlin.String origin=null + : kotlin.String + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .testNoNullCheck' + CALL 'public open fun notNullString (): kotlin.String declared in .J' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.kt new file mode 100644 index 00000000000..1ef154d4831 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.kt @@ -0,0 +1,20 @@ +// FILE: nnStringVsT.kt +fun useT(fn: () -> T) = fn() + +fun testNoNullCheck() { + useT { J.notNullString() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.txt new file mode 100644 index 00000000000..676e1489f16 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.txt @@ -0,0 +1,18 @@ +FILE fqName: fileName:/nnStringVsT.kt + FUN name:useT visibility:public modality:FINAL (fn:kotlin.Function0.useT>) returnType:T of .useT + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.useT> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useT (fn: kotlin.Function0.useT>): T of .useT declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useT origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useT> declared in .useT' type=kotlin.Function0.useT> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useT (fn: kotlin.Function0.useT>): T of .useT declared in ' type=@[EnhancedNullability] kotlin.String origin=null + : @[EnhancedNullability] kotlin.String + fn: FUN_EXPR type=kotlin.Function0<@[EnhancedNullability] kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:@[EnhancedNullability] kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): @[EnhancedNullability] kotlin.String declared in .testNoNullCheck' + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.fir.txt new file mode 100644 index 00000000000..dff53ccbe3a --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.fir.txt @@ -0,0 +1,18 @@ +FILE fqName: fileName:/nnStringVsTAny.kt + FUN name:useTAny visibility:public modality:FINAL (fn:kotlin.Function0.useTAny>) returnType:T of .useTAny + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] + VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.useTAny> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTAny (fn: kotlin.Function0.useTAny>): T of .useTAny declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTAny origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTAny> declared in .useTAny' type=kotlin.Function0.useTAny> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTAny (fn: kotlin.Function0.useTAny>): T of .useTAny declared in ' type=kotlin.String origin=null + : kotlin.String + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .testNoNullCheck' + CALL 'public open fun notNullString (): kotlin.String declared in .J' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.kt new file mode 100644 index 00000000000..6e63d7863f3 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.kt @@ -0,0 +1,20 @@ +// FILE: nnStringVsTAny.kt +fun useTAny(fn: () -> T) = fn() + +fun testNoNullCheck() { + useTAny { J.notNullString() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.txt new file mode 100644 index 00000000000..24df3e9d26e --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.txt @@ -0,0 +1,18 @@ +FILE fqName: fileName:/nnStringVsTAny.kt + FUN name:useTAny visibility:public modality:FINAL (fn:kotlin.Function0.useTAny>) returnType:T of .useTAny + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] + VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.useTAny> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTAny (fn: kotlin.Function0.useTAny>): T of .useTAny declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTAny origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTAny> declared in .useTAny' type=kotlin.Function0.useTAny> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTAny (fn: kotlin.Function0.useTAny>): T of .useTAny declared in ' type=@[EnhancedNullability] kotlin.String origin=null + : @[EnhancedNullability] kotlin.String + fn: FUN_EXPR type=kotlin.Function0<@[EnhancedNullability] kotlin.String> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:@[EnhancedNullability] kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): @[EnhancedNullability] kotlin.String declared in .testNoNullCheck' + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.fir.txt new file mode 100644 index 00000000000..cd95c1fb676 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.fir.txt @@ -0,0 +1,21 @@ +FILE fqName: fileName:/nnStringVsTConstrained.kt + FUN name:useTConstrained visibility:public modality:FINAL (xs:kotlin.Array.useTConstrained>, fn:kotlin.Function0.useTConstrained>) returnType:T of .useTConstrained + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:xs index:0 type:kotlin.Array.useTConstrained> + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTConstrained> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTConstrained (xs: kotlin.Array.useTConstrained>, fn: kotlin.Function0.useTConstrained>): T of .useTConstrained declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTConstrained origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTConstrained> declared in .useTConstrained' type=kotlin.Function0.useTConstrained> origin=VARIABLE_AS_FUNCTION + FUN name:testWithNullCheck visibility:public modality:FINAL <> (xs:kotlin.Array) returnType:kotlin.Unit + VALUE_PARAMETER name:xs index:0 type:kotlin.Array + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTConstrained (xs: kotlin.Array.useTConstrained>, fn: kotlin.Function0.useTConstrained>): T of .useTConstrained declared in ' type=kotlin.String origin=null + : kotlin.String + xs: GET_VAR 'xs: kotlin.Array declared in .testWithNullCheck' type=kotlin.Array origin=null + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .testWithNullCheck' + CALL 'public open fun notNullString (): kotlin.String declared in .J' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.kt new file mode 100644 index 00000000000..3a57193e5b8 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.kt @@ -0,0 +1,20 @@ +// FILE: nnStringVsTConstrained.kt +fun useTConstrained(xs: Array, fn: () -> T) = fn() + +fun testWithNullCheck(xs: Array) { + useTConstrained(xs) { J.notNullString() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.txt new file mode 100644 index 00000000000..80921078f9f --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.txt @@ -0,0 +1,21 @@ +FILE fqName: fileName:/nnStringVsTConstrained.kt + FUN name:useTConstrained visibility:public modality:FINAL (xs:kotlin.Array.useTConstrained>, fn:kotlin.Function0.useTConstrained>) returnType:T of .useTConstrained + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:xs index:0 type:kotlin.Array.useTConstrained> + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTConstrained> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTConstrained (xs: kotlin.Array.useTConstrained>, fn: kotlin.Function0.useTConstrained>): T of .useTConstrained declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTConstrained origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTConstrained> declared in .useTConstrained' type=kotlin.Function0.useTConstrained> origin=VARIABLE_AS_FUNCTION + FUN name:testWithNullCheck visibility:public modality:FINAL <> (xs:kotlin.Array) returnType:kotlin.Unit + VALUE_PARAMETER name:xs index:0 type:kotlin.Array + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTConstrained (xs: kotlin.Array.useTConstrained>, fn: kotlin.Function0.useTConstrained>): T of .useTConstrained declared in ' type=kotlin.String origin=null + : kotlin.String + xs: GET_VAR 'xs: kotlin.Array declared in .testWithNullCheck' type=kotlin.Array origin=null + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .testWithNullCheck' + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.fir.txt new file mode 100644 index 00000000000..ef5d8dfee55 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.fir.txt @@ -0,0 +1,21 @@ +FILE fqName: fileName:/nnStringVsTXArray.kt + FUN name:useTX visibility:public modality:FINAL (x:T of .useTX, fn:kotlin.Function0.useTX>) returnType:T of .useTX + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:x index:0 type:T of .useTX + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTX> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTX origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTX> declared in .useTX' type=kotlin.Function0.useTX> origin=VARIABLE_AS_FUNCTION + FUN name:testWithNullCheck visibility:public modality:FINAL <> (xs:kotlin.Array) returnType:kotlin.Unit + VALUE_PARAMETER name:xs index:0 type:kotlin.Array + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' type=java.io.Serializable origin=null + : java.io.Serializable + x: GET_VAR 'xs: kotlin.Array declared in .testWithNullCheck' type=kotlin.Array origin=null + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:java.io.Serializable + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): java.io.Serializable declared in .testWithNullCheck' + CALL 'public open fun notNullString (): kotlin.String declared in .J' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.kt new file mode 100644 index 00000000000..43bcbfe5210 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.kt @@ -0,0 +1,20 @@ +// FILE: nnStringVsTXArray.kt +fun useTX(x: T, fn: () -> T) = fn() + +fun testWithNullCheck(xs: Array) { + useTX(xs) { J.notNullString() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.txt new file mode 100644 index 00000000000..2de28daa0c9 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.txt @@ -0,0 +1,21 @@ +FILE fqName: fileName:/nnStringVsTXArray.kt + FUN name:useTX visibility:public modality:FINAL (x:T of .useTX, fn:kotlin.Function0.useTX>) returnType:T of .useTX + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:x index:0 type:T of .useTX + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTX> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTX origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTX> declared in .useTX' type=kotlin.Function0.useTX> origin=VARIABLE_AS_FUNCTION + FUN name:testWithNullCheck visibility:public modality:FINAL <> (xs:kotlin.Array) returnType:kotlin.Unit + VALUE_PARAMETER name:xs index:0 type:kotlin.Array + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' type=java.io.Serializable origin=null + : java.io.Serializable + x: GET_VAR 'xs: kotlin.Array declared in .testWithNullCheck' type=kotlin.Array origin=null + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:java.io.Serializable + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): java.io.Serializable declared in .testWithNullCheck' + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.fir.txt new file mode 100644 index 00000000000..05444d3a953 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.fir.txt @@ -0,0 +1,20 @@ +FILE fqName: fileName:/nnStringVsTXString.kt + FUN name:useTX visibility:public modality:FINAL (x:T of .useTX, fn:kotlin.Function0.useTX>) returnType:T of .useTX + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:x index:0 type:T of .useTX + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTX> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTX origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTX> declared in .useTX' type=kotlin.Function0.useTX> origin=VARIABLE_AS_FUNCTION + FUN name:testWithNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' type=kotlin.String origin=null + : kotlin.String + x: CONST String type=kotlin.String value="" + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .testWithNullCheck' + CALL 'public open fun notNullString (): kotlin.String declared in .J' type=kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt new file mode 100644 index 00000000000..c1879f227ba --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt @@ -0,0 +1,20 @@ +// FILE: nnStringVsTXString.kt +fun useTX(x: T, fn: () -> T) = fn() + +fun testWithNullCheck { + useTX("") { J.notNullString() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.txt new file mode 100644 index 00000000000..7ee64ace1df --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.txt @@ -0,0 +1,20 @@ +FILE fqName: fileName:/nnStringVsTXString.kt + FUN name:useTX visibility:public modality:FINAL (x:T of .useTX, fn:kotlin.Function0.useTX>) returnType:T of .useTX + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:x index:0 type:T of .useTX + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTX> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTX origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTX> declared in .useTX' type=kotlin.Function0.useTX> origin=VARIABLE_AS_FUNCTION + FUN name:testWithNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' type=kotlin.String origin=null + : kotlin.String + x: CONST String type=kotlin.String value="" + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .testWithNullCheck' + CALL 'public open fun notNullString (): @[EnhancedNullability] kotlin.String declared in .J' type=@[EnhancedNullability] kotlin.String origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.fir.txt new file mode 100644 index 00000000000..ce6b0044180 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.fir.txt @@ -0,0 +1,18 @@ +FILE fqName: fileName:/stringVsT.kt + FUN name:useT visibility:public modality:FINAL (fn:kotlin.Function0.useT>) returnType:T of .useT + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.useT> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useT (fn: kotlin.Function0.useT>): T of .useT declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useT origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useT> declared in .useT' type=kotlin.Function0.useT> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useT (fn: kotlin.Function0.useT>): T of .useT declared in ' type=kotlin.String? origin=null + : kotlin.String? + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String? declared in .testNoNullCheck' + CALL 'public open fun string (): kotlin.String? declared in .J' type=kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.kt new file mode 100644 index 00000000000..fb8aa91ffb1 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.kt @@ -0,0 +1,20 @@ +// FILE: stringVsT.kt +fun useT(fn: () -> T) = fn() + +fun testNoNullCheck() { + useT { J.string() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.txt new file mode 100644 index 00000000000..7cde686a9bb --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.txt @@ -0,0 +1,18 @@ +FILE fqName: fileName:/stringVsT.kt + FUN name:useT visibility:public modality:FINAL (fn:kotlin.Function0.useT>) returnType:T of .useT + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.useT> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useT (fn: kotlin.Function0.useT>): T of .useT declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useT origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useT> declared in .useT' type=kotlin.Function0.useT> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useT (fn: kotlin.Function0.useT>): T of .useT declared in ' type=@[FlexibleNullability] kotlin.String? origin=null + : @[FlexibleNullability] kotlin.String? + fn: FUN_EXPR type=kotlin.Function0<@[FlexibleNullability] kotlin.String?> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:@[FlexibleNullability] kotlin.String? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): @[FlexibleNullability] kotlin.String? declared in .testNoNullCheck' + CALL 'public open fun string (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.fir.txt new file mode 100644 index 00000000000..55c9a7ce568 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.fir.txt @@ -0,0 +1,18 @@ +FILE fqName: fileName:/stringVsTAny.kt + FUN name:useTAny visibility:public modality:FINAL (fn:kotlin.Function0.useTAny>) returnType:T of .useTAny + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] + VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.useTAny> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTAny (fn: kotlin.Function0.useTAny>): T of .useTAny declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTAny origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTAny> declared in .useTAny' type=kotlin.Function0.useTAny> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTAny (fn: kotlin.Function0.useTAny>): T of .useTAny declared in ' type=kotlin.String? origin=null + : kotlin.String? + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String? declared in .testNoNullCheck' + CALL 'public open fun string (): kotlin.String? declared in .J' type=kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.kt new file mode 100644 index 00000000000..c3de797ff94 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.kt @@ -0,0 +1,20 @@ +// FILE: stringVsTAny.kt +fun useTAny(fn: () -> T) = fn() + +fun testNoNullCheck() { + useTAny { J.string() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.txt new file mode 100644 index 00000000000..1afb59a44d2 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.txt @@ -0,0 +1,18 @@ +FILE fqName: fileName:/stringVsTAny.kt + FUN name:useTAny visibility:public modality:FINAL (fn:kotlin.Function0.useTAny>) returnType:T of .useTAny + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any] + VALUE_PARAMETER name:fn index:0 type:kotlin.Function0.useTAny> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTAny (fn: kotlin.Function0.useTAny>): T of .useTAny declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTAny origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTAny> declared in .useTAny' type=kotlin.Function0.useTAny> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTAny (fn: kotlin.Function0.useTAny>): T of .useTAny declared in ' type=@[FlexibleNullability] kotlin.String? origin=null + : @[FlexibleNullability] kotlin.String? + fn: FUN_EXPR type=kotlin.Function0<@[FlexibleNullability] kotlin.String?> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:@[FlexibleNullability] kotlin.String? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): @[FlexibleNullability] kotlin.String? declared in .testNoNullCheck' + CALL 'public open fun string (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.txt new file mode 100644 index 00000000000..9072f71313c --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.fir.txt @@ -0,0 +1,21 @@ +FILE fqName: fileName:/stringVsTConstrained.kt + FUN name:useTConstrained visibility:public modality:FINAL (xs:kotlin.Array.useTConstrained>, fn:kotlin.Function0.useTConstrained>) returnType:T of .useTConstrained + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:xs index:0 type:kotlin.Array.useTConstrained> + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTConstrained> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTConstrained (xs: kotlin.Array.useTConstrained>, fn: kotlin.Function0.useTConstrained>): T of .useTConstrained declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTConstrained origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTConstrained> declared in .useTConstrained' type=kotlin.Function0.useTConstrained> origin=VARIABLE_AS_FUNCTION + FUN name:testWithNullCheck visibility:public modality:FINAL <> (xs:kotlin.Array) returnType:kotlin.Unit + VALUE_PARAMETER name:xs index:0 type:kotlin.Array + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTConstrained (xs: kotlin.Array.useTConstrained>, fn: kotlin.Function0.useTConstrained>): T of .useTConstrained declared in ' type=kotlin.String origin=null + : kotlin.String + xs: GET_VAR 'xs: kotlin.Array declared in .testWithNullCheck' type=kotlin.Array origin=null + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .testWithNullCheck' + CALL 'public open fun string (): kotlin.String? declared in .J' type=kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt new file mode 100644 index 00000000000..ee3c9c04f22 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt @@ -0,0 +1,20 @@ +// FILE: stringVsTConstrained.kt +fun useTConstrained(xs: Array, fn: () -> T) = fn() + +fun testWithNullCheck(xs: Array) { + useTConstrained(xs) { J.string() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.txt new file mode 100644 index 00000000000..a3a51c7acaf --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.txt @@ -0,0 +1,22 @@ +FILE fqName: fileName:/stringVsTConstrained.kt + FUN name:useTConstrained visibility:public modality:FINAL (xs:kotlin.Array.useTConstrained>, fn:kotlin.Function0.useTConstrained>) returnType:T of .useTConstrained + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:xs index:0 type:kotlin.Array.useTConstrained> + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTConstrained> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTConstrained (xs: kotlin.Array.useTConstrained>, fn: kotlin.Function0.useTConstrained>): T of .useTConstrained declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTConstrained origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTConstrained> declared in .useTConstrained' type=kotlin.Function0.useTConstrained> origin=VARIABLE_AS_FUNCTION + FUN name:testWithNullCheck visibility:public modality:FINAL <> (xs:kotlin.Array) returnType:kotlin.Unit + VALUE_PARAMETER name:xs index:0 type:kotlin.Array + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTConstrained (xs: kotlin.Array.useTConstrained>, fn: kotlin.Function0.useTConstrained>): T of .useTConstrained declared in ' type=kotlin.String origin=null + : kotlin.String + xs: GET_VAR 'xs: kotlin.Array declared in .testWithNullCheck' type=kotlin.Array origin=null + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String declared in .testWithNullCheck' + TYPE_OP type=kotlin.String origin=IMPLICIT_NOTNULL typeOperand=kotlin.String + CALL 'public open fun string (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.txt new file mode 100644 index 00000000000..09ed2f34a77 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.fir.txt @@ -0,0 +1,21 @@ +FILE fqName: fileName:/stringVsTXArray.kt + FUN name:useTX visibility:public modality:FINAL (x:T of .useTX, fn:kotlin.Function0.useTX>) returnType:T of .useTX + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:x index:0 type:T of .useTX + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTX> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTX origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTX> declared in .useTX' type=kotlin.Function0.useTX> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> (xs:kotlin.Array) returnType:kotlin.Unit + VALUE_PARAMETER name:xs index:0 type:kotlin.Array + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' type=java.io.Serializable? origin=null + : java.io.Serializable? + x: GET_VAR 'xs: kotlin.Array declared in .testNoNullCheck' type=kotlin.Array origin=null + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String? declared in .testNoNullCheck' + CALL 'public open fun string (): kotlin.String? declared in .J' type=kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.kt new file mode 100644 index 00000000000..bd624e94ce0 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.kt @@ -0,0 +1,20 @@ +// FILE: stringVsTXArray.kt +fun useTX(x: T, fn: () -> T) = fn() + +fun testNoNullCheck(xs: Array) { + useTX(xs) { J.string() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.txt new file mode 100644 index 00000000000..b12dc5084f7 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.txt @@ -0,0 +1,21 @@ +FILE fqName: fileName:/stringVsTXArray.kt + FUN name:useTX visibility:public modality:FINAL (x:T of .useTX, fn:kotlin.Function0.useTX>) returnType:T of .useTX + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:x index:0 type:T of .useTX + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTX> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTX origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTX> declared in .useTX' type=kotlin.Function0.useTX> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> (xs:kotlin.Array) returnType:kotlin.Unit + VALUE_PARAMETER name:xs index:0 type:kotlin.Array + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' type=@[FlexibleNullability] java.io.Serializable? origin=null + : @[FlexibleNullability] java.io.Serializable? + x: GET_VAR 'xs: kotlin.Array declared in .testNoNullCheck' type=kotlin.Array origin=null + fn: FUN_EXPR type=kotlin.Function0<@[FlexibleNullability] java.io.Serializable?> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:@[FlexibleNullability] java.io.Serializable? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): @[FlexibleNullability] java.io.Serializable? declared in .testNoNullCheck' + CALL 'public open fun string (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.fir.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.fir.txt new file mode 100644 index 00000000000..893a282df0f --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.fir.txt @@ -0,0 +1,20 @@ +FILE fqName: fileName:/stringVsTXString.kt + FUN name:useTX visibility:public modality:FINAL (x:T of .useTX, fn:kotlin.Function0.useTX>) returnType:T of .useTX + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:x index:0 type:T of .useTX + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTX> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTX origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTX> declared in .useTX' type=kotlin.Function0.useTX> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' type=kotlin.String? origin=null + : kotlin.String? + x: CONST String type=kotlin.String value="" + fn: FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.String? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.String? declared in .testNoNullCheck' + CALL 'public open fun string (): kotlin.String? declared in .J' type=kotlin.String? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.kt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.kt new file mode 100644 index 00000000000..c4140d09fd9 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.kt @@ -0,0 +1,20 @@ +// FILE: stringVsTXString.kt +fun useTX(x: T, fn: () -> T) = fn() + +fun testNoNullCheck() { + useTX("") { J.string() } +} + +// FILE: J.java +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class J { + public static String string() { + return null; + } + + public static @NotNull String notNullString() { + return null; + } +} diff --git a/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.txt b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.txt new file mode 100644 index 00000000000..196f1037e62 --- /dev/null +++ b/compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.txt @@ -0,0 +1,20 @@ +FILE fqName: fileName:/stringVsTXString.kt + FUN name:useTX visibility:public modality:FINAL (x:T of .useTX, fn:kotlin.Function0.useTX>) returnType:T of .useTX + TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.Any?] + VALUE_PARAMETER name:x index:0 type:T of .useTX + VALUE_PARAMETER name:fn index:1 type:kotlin.Function0.useTX> + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' + CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=T of .useTX origin=INVOKE + $this: GET_VAR 'fn: kotlin.Function0.useTX> declared in .useTX' type=kotlin.Function0.useTX> origin=VARIABLE_AS_FUNCTION + FUN name:testNoNullCheck visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun useTX (x: T of .useTX, fn: kotlin.Function0.useTX>): T of .useTX declared in ' type=@[FlexibleNullability] kotlin.String? origin=null + : @[FlexibleNullability] kotlin.String? + x: CONST String type=kotlin.String value="" + fn: FUN_EXPR type=kotlin.Function0<@[FlexibleNullability] kotlin.String?> origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:@[FlexibleNullability] kotlin.String? + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): @[FlexibleNullability] kotlin.String? declared in .testNoNullCheck' + CALL 'public open fun string (): @[FlexibleNullability] kotlin.String? declared in .J' type=@[FlexibleNullability] kotlin.String? origin=null diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 28bf29bac73..4e3bb6c9e40 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -17379,6 +17379,69 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inTopLevelPropertyInitializer.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullCheckOnLambdaReturnValue extends AbstractBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInNullCheckOnLambdaReturnValue() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("nnStringVsT.kt") + public void testNnStringVsT() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsT.kt"); + } + + @TestMetadata("nnStringVsTAny.kt") + public void testNnStringVsTAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTAny.kt"); + } + + @TestMetadata("nnStringVsTConstrained.kt") + public void testNnStringVsTConstrained() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTConstrained.kt"); + } + + @TestMetadata("nnStringVsTXArray.kt") + public void testNnStringVsTXArray() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXArray.kt"); + } + + @TestMetadata("nnStringVsTXString.kt") + public void testNnStringVsTXString() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXString.kt"); + } + + @TestMetadata("stringVsT.kt") + public void testStringVsT() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsT.kt"); + } + + @TestMetadata("stringVsTAny.kt") + public void testStringVsTAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTAny.kt"); + } + + @TestMetadata("stringVsTConstrained.kt") + public void testStringVsTConstrained() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTConstrained.kt"); + } + + @TestMetadata("stringVsTXArray.kt") + public void testStringVsTXArray() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXArray.kt"); + } + + @TestMetadata("stringVsTXString.kt") + public void testStringVsTXString() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXString.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/javaInterop/objectMethods") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index e6e874cd39e..7dd4edaebfc 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -17379,6 +17379,69 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inTopLevelPropertyInitializer.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullCheckOnLambdaReturnValue extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInNullCheckOnLambdaReturnValue() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("nnStringVsT.kt") + public void testNnStringVsT() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsT.kt"); + } + + @TestMetadata("nnStringVsTAny.kt") + public void testNnStringVsTAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTAny.kt"); + } + + @TestMetadata("nnStringVsTConstrained.kt") + public void testNnStringVsTConstrained() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTConstrained.kt"); + } + + @TestMetadata("nnStringVsTXArray.kt") + public void testNnStringVsTXArray() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXArray.kt"); + } + + @TestMetadata("nnStringVsTXString.kt") + public void testNnStringVsTXString() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXString.kt"); + } + + @TestMetadata("stringVsT.kt") + public void testStringVsT() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsT.kt"); + } + + @TestMetadata("stringVsTAny.kt") + public void testStringVsTAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTAny.kt"); + } + + @TestMetadata("stringVsTConstrained.kt") + public void testStringVsTConstrained() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTConstrained.kt"); + } + + @TestMetadata("stringVsTXArray.kt") + public void testStringVsTXArray() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXArray.kt"); + } + + @TestMetadata("stringVsTXString.kt") + public void testStringVsTXString() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXString.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/javaInterop/objectMethods") diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 35d06df29e7..1696bb0f15e 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -15979,6 +15979,69 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability/inTopLevelPropertyInitializer.kt"); } } + + @TestMetadata("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullCheckOnLambdaReturnValue extends AbstractIrBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInNullCheckOnLambdaReturnValue() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @TestMetadata("nnStringVsT.kt") + public void testNnStringVsT() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsT.kt"); + } + + @TestMetadata("nnStringVsTAny.kt") + public void testNnStringVsTAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTAny.kt"); + } + + @TestMetadata("nnStringVsTConstrained.kt") + public void testNnStringVsTConstrained() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTConstrained.kt"); + } + + @TestMetadata("nnStringVsTXArray.kt") + public void testNnStringVsTXArray() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXArray.kt"); + } + + @TestMetadata("nnStringVsTXString.kt") + public void testNnStringVsTXString() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/nnStringVsTXString.kt"); + } + + @TestMetadata("stringVsT.kt") + public void testStringVsT() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsT.kt"); + } + + @TestMetadata("stringVsTAny.kt") + public void testStringVsTAny() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTAny.kt"); + } + + @TestMetadata("stringVsTConstrained.kt") + public void testStringVsTConstrained() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTConstrained.kt"); + } + + @TestMetadata("stringVsTXArray.kt") + public void testStringVsTXArray() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXArray.kt"); + } + + @TestMetadata("stringVsTXString.kt") + public void testStringVsTXString() throws Exception { + runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue/stringVsTXString.kt"); + } + } } @TestMetadata("compiler/testData/codegen/box/javaInterop/objectMethods") diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 7e49c1b10a8..5fc7af29e50 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -2160,6 +2160,69 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { public void testPlatformTypeReceiver() throws Exception { runTest("compiler/testData/ir/irText/types/nullChecks/platformTypeReceiver.kt"); } + + @TestMetadata("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullCheckOnLambdaResult extends AbstractIrTextTestCase { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInNullCheckOnLambdaResult() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult"), Pattern.compile("^(.+)\\.kt$"), null, true); + } + + @TestMetadata("nnStringVsT.kt") + public void testNnStringVsT() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsT.kt"); + } + + @TestMetadata("nnStringVsTAny.kt") + public void testNnStringVsTAny() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTAny.kt"); + } + + @TestMetadata("nnStringVsTConstrained.kt") + public void testNnStringVsTConstrained() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTConstrained.kt"); + } + + @TestMetadata("nnStringVsTXArray.kt") + public void testNnStringVsTXArray() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXArray.kt"); + } + + @TestMetadata("nnStringVsTXString.kt") + public void testNnStringVsTXString() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/nnStringVsTXString.kt"); + } + + @TestMetadata("stringVsT.kt") + public void testStringVsT() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsT.kt"); + } + + @TestMetadata("stringVsTAny.kt") + public void testStringVsTAny() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTAny.kt"); + } + + @TestMetadata("stringVsTConstrained.kt") + public void testStringVsTConstrained() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTConstrained.kt"); + } + + @TestMetadata("stringVsTXArray.kt") + public void testStringVsTXArray() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXArray.kt"); + } + + @TestMetadata("stringVsTXString.kt") + public void testStringVsTXString() throws Exception { + runTest("compiler/testData/ir/irText/types/nullChecks/nullCheckOnLambdaResult/stringVsTXString.kt"); + } + } } } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 61381efb420..f556dfb0522 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -13724,6 +13724,19 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } } + + @TestMetadata("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullCheckOnLambdaReturnValue extends AbstractIrJsCodegenBoxES6Test { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); + } + + public void testAllFilesPresentInNullCheckOnLambdaReturnValue() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + } } @TestMetadata("compiler/testData/codegen/box/javaInterop/objectMethods") diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 0e6ed5f424b..cc8b5e710a6 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -13724,6 +13724,19 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } } + + @TestMetadata("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullCheckOnLambdaReturnValue extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInNullCheckOnLambdaReturnValue() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + } } @TestMetadata("compiler/testData/codegen/box/javaInterop/objectMethods") diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 309b144e2a5..cbb386dca34 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -13789,6 +13789,19 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop/notNullAssertions/enhancedNullability"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } } + + @TestMetadata("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class NullCheckOnLambdaReturnValue extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInNullCheckOnLambdaReturnValue() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/javaInterop/notNullAssertions/nullCheckOnLambdaReturnValue"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + } } @TestMetadata("compiler/testData/codegen/box/javaInterop/objectMethods")