K2: reproduce KT-59748

This commit is contained in:
Mikhail Glukhikh
2023-07-24 22:03:47 +02:00
committed by Space Team
parent a428ab6ed6
commit 1832413a02
8 changed files with 77 additions and 0 deletions
@@ -0,0 +1,12 @@
// ISSUE: KT-59748
// FIR_DUMP
fun foo(list: MutableList<Any?>, condition: Boolean): Unit = <!RETURN_TYPE_MISMATCH!>when {
condition -> list[0] = ""
else -> Unit
}<!>
fun bar(list: MutableList<Any?>, condition: Boolean): Unit = <!RETURN_TYPE_MISMATCH!>when {
condition -> list.set(0, "")
else -> Unit
}<!>
@@ -0,0 +1,23 @@
FILE: listAssignmentInWhen.fir.kt
public final fun foo(list: R|kotlin/collections/MutableList<kotlin/Any?>|, condition: R|kotlin/Boolean|): R|kotlin/Unit| {
^foo when () {
R|<local>/condition| -> {
R|<local>/list|.R|SubstitutionOverride<kotlin/collections/MutableList.set: R|kotlin/Any?|>|(Int(0), String())
}
else -> {
Q|kotlin/Unit|
}
}
}
public final fun bar(list: R|kotlin/collections/MutableList<kotlin/Any?>|, condition: R|kotlin/Boolean|): R|kotlin/Unit| {
^bar when () {
R|<local>/condition| -> {
R|<local>/list|.R|SubstitutionOverride<kotlin/collections/MutableList.set: R|kotlin/Any?|>|(Int(0), String())
}
else -> {
Q|kotlin/Unit|
}
}
}
@@ -0,0 +1,12 @@
// ISSUE: KT-59748
// FIR_DUMP
fun foo(list: MutableList<Any?>, condition: Boolean): Unit = when {
condition -> list[0] = ""
else -> Unit
}
fun bar(list: MutableList<Any?>, condition: Boolean): Unit = <!TYPE_MISMATCH!>when {
condition -> list.set(0, "")
else -> Unit
}<!>