NI: add test for KT-37628
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -NAME_SHADOWING -UNUSED_VARIABLE
|
||||
|
||||
fun foo1(x: Int) {
|
||||
val x = if (true) { // OI: Map<String, () → Int>?, NI: Nothing?, error
|
||||
"" to { x }
|
||||
} else { null }
|
||||
|
||||
x
|
||||
}
|
||||
|
||||
fun foo2(x: Int) {
|
||||
val x = if (true) {
|
||||
mapOf("" to { x }) // `Map<String, () → Int>` is in type info in IDE
|
||||
} else {
|
||||
null
|
||||
} // Fixed the problem: "type of entire `if` is `Map<String, *>?` (NI) instead of `Map<String, () → Int>?` (OI)"
|
||||
|
||||
x
|
||||
}
|
||||
@@ -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<String, () → Int>?, NI: Nothing?, error
|
||||
"" to { x }
|
||||
} else { null }
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Pair<kotlin.String, () -> kotlin.Int>?")!>x<!>
|
||||
}
|
||||
|
||||
fun foo2(x: Int) {
|
||||
val x = if (true) {
|
||||
mapOf("" to { x }) // `Map<String, () → Int>` is in type info in IDE
|
||||
} else {
|
||||
null
|
||||
} // Fixed the problem: "type of entire `if` is `Map<String, *>?` (NI) instead of `Map<String, () → Int>?` (OI)"
|
||||
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.collections.Map<kotlin.String, () -> kotlin.Int>?")!>x<!>
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user