[FIR2IR] Don't replace while loop and when branch body blocks with single expression. Skip some empty blocks.
https://youtrack.jetbrains.com/issue/KT-60264/K2-while-loop-body-block-sometimes-replaced-with-single-expression Merge-request: KT-MR-12035 Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
f4df4f8007
commit
9a2eff6487
Vendored
+13
-4
@@ -19,7 +19,9 @@ fun <T> test0(a: T) where T : KRunnable, T : Function0<Unit> {
|
||||
|
||||
fun test1(a: Function0<Unit>) {
|
||||
when {
|
||||
a is KRunnable -> run1(r = a /*as KRunnable */)
|
||||
a is KRunnable -> { // BLOCK
|
||||
run1(r = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,19 +32,25 @@ fun test2(a: KRunnable) {
|
||||
|
||||
fun test3(a: Function0<Unit>) {
|
||||
when {
|
||||
a is KRunnable -> run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */)
|
||||
a is KRunnable -> { // BLOCK
|
||||
run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
|
||||
when {
|
||||
a is KRunnable -> run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */)
|
||||
a is KRunnable -> { // BLOCK
|
||||
run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(a: Any) {
|
||||
when {
|
||||
a is KRunnable -> run1(r = a /*as KRunnable */)
|
||||
a is KRunnable -> { // BLOCK
|
||||
run1(r = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,3 +97,4 @@ fun test8(a: Function0<Unit>) {
|
||||
fun test9() {
|
||||
run1(r = ::test9 /*-> KRunnable */)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user