diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.fir.kt new file mode 100644 index 00000000000..e0aac42b51a --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.fir.kt @@ -0,0 +1,21 @@ +// FIR_IDENTICAL +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -NAME_SHADOWING -UNUSED_VARIABLE + +fun foo1(x: Int) { + val x = if (true) { // OI: Map?, NI: Nothing?, error + "" to { x } + } else { null } + + x +} + +fun foo2(x: Int) { + val x = if (true) { + mapOf("" to { x }) // `Map` is in type info in IDE + } else { + null + } // Fixed the problem: "type of entire `if` is `Map?` (NI) instead of `Map?` (OI)" + + x +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.kt index c9026d6a44e..f74d0c326b4 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.kt @@ -1,9 +1,20 @@ -// FIR_IDENTICAL // !LANGUAGE: +NewInference -// !DIAGNOSTICS: -NAME_SHADOWING -UNUSED_VARIABLE +// !DIAGNOSTICS: -NAME_SHADOWING -UNUSED_VARIABLE -UNUSED_EXPRESSION -fun foo(x: Int) { +fun foo1(x: Int) { val x = if (true) { // OI: Map?, NI: Nothing?, error "" to { x } } else { null } + + kotlin.Int>?")!>x +} + +fun foo2(x: Int) { + val x = if (true) { + mapOf("" to { x }) // `Map` is in type info in IDE + } else { + null + } // Fixed the problem: "type of entire `if` is `Map?` (NI) instead of `Map?` (OI)" + + kotlin.Int>?")!>x } diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.txt index 3afacee3aa4..90e8b1a4c84 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt37627.txt @@ -1,3 +1,4 @@ package -public fun foo(/*0*/ x: kotlin.Int): kotlin.Unit +public fun foo1(/*0*/ x: kotlin.Int): kotlin.Unit +public fun foo2(/*0*/ x: kotlin.Int): kotlin.Unit