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 b3565308c01..781ee4fa8ca 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 @@ -12627,6 +12627,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inference/noCoercionToUniForNullableLambdaReturnType.kt"); } + @TestMetadata("noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt") + public void testNoCoercionToUnitWithEqualityConstraintForNullableReturnType() throws Exception { + runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt"); + } + @TestMetadata("noNothingValueInsideSpecialCall.kt") public void testNoNothingValueInsideSpecialCall() throws Exception { runTest("compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.kt"); diff --git a/compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt b/compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt new file mode 100644 index 00000000000..1c5250a327e --- /dev/null +++ b/compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt @@ -0,0 +1,14 @@ +// IGNORE_BACKEND_FIR: JVM_IR + +class Inv(val x: T?) + +fun foo(f: () -> R?): Inv { + val r = f() + if (r != null) throw Exception("fail, result is not null: $r") + return Inv(r) +} + +fun box(): String { + val r: Inv = foo { if (false) Unit else null } + return "OK" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 9cc3515d4d8..459597c1152 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -13852,6 +13852,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inference/noCoercionToUniForNullableLambdaReturnType.kt"); } + @TestMetadata("noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt") + public void testNoCoercionToUnitWithEqualityConstraintForNullableReturnType() throws Exception { + runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt"); + } + @TestMetadata("noNothingValueInsideSpecialCall.kt") public void testNoNothingValueInsideSpecialCall() throws Exception { runTest("compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index df95e39baef..3b265583452 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13852,6 +13852,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inference/noCoercionToUniForNullableLambdaReturnType.kt"); } + @TestMetadata("noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt") + public void testNoCoercionToUnitWithEqualityConstraintForNullableReturnType() throws Exception { + runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt"); + } + @TestMetadata("noNothingValueInsideSpecialCall.kt") public void testNoNothingValueInsideSpecialCall() throws Exception { runTest("compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 1fcbcc04e87..39438f9f2a8 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -12627,6 +12627,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inference/noCoercionToUniForNullableLambdaReturnType.kt"); } + @TestMetadata("noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt") + public void testNoCoercionToUnitWithEqualityConstraintForNullableReturnType() throws Exception { + runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt"); + } + @TestMetadata("noNothingValueInsideSpecialCall.kt") public void testNoNothingValueInsideSpecialCall() throws Exception { runTest("compiler/testData/codegen/box/inference/noNothingValueInsideSpecialCall.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 18dae5e35f9..2ed565ce31b 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 @@ -10807,6 +10807,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/inference/noCoercionToUniForNullableLambdaReturnType.kt"); } + @TestMetadata("noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt") + public void testNoCoercionToUnitWithEqualityConstraintForNullableReturnType() throws Exception { + runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt"); + } + @TestMetadata("plusAssignInsideLambda.kt") public void testPlusAssignInsideLambda() throws Exception { runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt"); 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 3519e89bc8c..057d13d6701 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 @@ -10807,6 +10807,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inference/noCoercionToUniForNullableLambdaReturnType.kt"); } + @TestMetadata("noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt") + public void testNoCoercionToUnitWithEqualityConstraintForNullableReturnType() throws Exception { + runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt"); + } + @TestMetadata("plusAssignInsideLambda.kt") public void testPlusAssignInsideLambda() throws Exception { runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt"); 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 c78f613c572..83374954f0f 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 @@ -10872,6 +10872,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inference/noCoercionToUniForNullableLambdaReturnType.kt"); } + @TestMetadata("noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt") + public void testNoCoercionToUnitWithEqualityConstraintForNullableReturnType() throws Exception { + runTest("compiler/testData/codegen/box/inference/noCoercionToUnitWithEqualityConstraintForNullableReturnType.kt"); + } + @TestMetadata("plusAssignInsideLambda.kt") public void testPlusAssignInsideLambda() throws Exception { runTest("compiler/testData/codegen/box/inference/plusAssignInsideLambda.kt");