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,44 +0,0 @@
|
||||
// !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() = <!RETURN_TYPE_MISMATCH!>when (e) {
|
||||
E.VALUE -> { param ->
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>method<!>(param)
|
||||
}
|
||||
}<!>
|
||||
|
||||
val withExplicitType: LambdaWithReceiver
|
||||
get() = <!RETURN_TYPE_MISMATCH!>when (e) {
|
||||
E.VALUE -> { param: Parameter ->
|
||||
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>method<!>(param)
|
||||
}
|
||||
}<!>
|
||||
}
|
||||
|
||||
class OtherClass {
|
||||
val ok: LambdaWithReceiver
|
||||
get() = { param: Parameter ->
|
||||
method(param)
|
||||
}
|
||||
}
|
||||
|
||||
val e2 = E.VALUE
|
||||
val staticWithExplicitType: LambdaWithReceiver
|
||||
get() = <!RETURN_TYPE_MISMATCH!>when (e2) {
|
||||
E.VALUE -> { param: Parameter ->
|
||||
<!UNRESOLVED_REFERENCE!>method<!>(param)
|
||||
}
|
||||
}<!>
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
interface Receiver
|
||||
|
||||
Reference in New Issue
Block a user