K2: Optimize one-branch when-expr case only for independent context
Using independent one where `when` is nested doesn't look correct
This commit is contained in:
committed by
Space Team
parent
04d3996e68
commit
8f8ea8c57f
@@ -1,17 +0,0 @@
|
||||
import java.util.*
|
||||
import kotlin.comparisons.compareBy
|
||||
import kotlin.comparisons.nullsLast
|
||||
|
||||
class Foo(val a: String, val b: Int)
|
||||
|
||||
fun getComp(): Comparator<Foo?> =
|
||||
when {
|
||||
else -> <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>nullsLast<!>(compareBy({ it.<!UNRESOLVED_REFERENCE!>a<!> }, { it.<!UNRESOLVED_REFERENCE!>b<!> }))
|
||||
}
|
||||
|
||||
fun getCompInverted(): Comparator<Foo?> =
|
||||
nullsLast(
|
||||
when {
|
||||
else -> <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>compareBy<!>({ it.<!UNRESOLVED_REFERENCE!>a<!> }, { it.<!UNRESOLVED_REFERENCE!>b<!> })
|
||||
}
|
||||
)
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
import java.util.*
|
||||
import kotlin.comparisons.compareBy
|
||||
import kotlin.comparisons.nullsLast
|
||||
@@ -14,4 +15,4 @@ fun getCompInverted(): Comparator<Foo?> =
|
||||
when {
|
||||
else -> compareBy({ it.a }, { it.b })
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user