Files
Denis.Zharkov 8f8ea8c57f K2: Optimize one-branch when-expr case only for independent context
Using independent one where `when` is nested doesn't look correct
2023-02-15 08:13:43 +00:00

46 lines
954 B
Kotlin
Vendored

// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
interface Receiver
interface Parameter
typealias LambdaWithReceiver = Receiver.(Parameter) -> Unit
fun Receiver.method(param: Parameter): LambdaWithReceiver = TODO()
enum class E { VALUE }
fun <K> id(x: K): K = x
class SomeClass {
val e = E.VALUE
val withoutType: LambdaWithReceiver
get() = when (e) {
E.VALUE -> { param ->
method(param)
}
}
val withExplicitType: LambdaWithReceiver
get() = when (e) {
E.VALUE -> { param: Parameter ->
method(param)
}
}
}
class OtherClass {
val ok: LambdaWithReceiver
get() = { param: Parameter ->
method(param)
}
}
val e2 = E.VALUE
val staticWithExplicitType: LambdaWithReceiver
get() = when (e2) {
E.VALUE -> { param: Parameter ->
method(param)
}
}