"Replace if with when": Do not remove block braces if block has single lambda expression #KT-26187 Fixed

This commit is contained in:
Toshiaki Kameyama
2018-08-17 13:38:19 +09:00
committed by Mikhail Glukhikh
parent e59427edab
commit 362e6863ac
6 changed files with 57 additions and 1 deletions
@@ -0,0 +1,9 @@
fun test(x: Int) {
val f: Function<Int> = <caret>if (x == 0) {
{ 0 }
} else if (x == 1) {
{ 1 }
} else {
{ 2 }
}
}
@@ -0,0 +1,13 @@
fun test(x: Int) {
val f: Function<Int> = when (x) {
0 -> {
{ 0 }
}
1 -> {
{ 1 }
}
else -> {
{ 2 }
}
}
}
@@ -0,0 +1,9 @@
fun test(x: Int) {
val f: Function<Int> = <caret>if (x == 0) {
({ 0 })
} else if (x == 1) {
(({ 1 }))
} else {
((({ 2 })))
}
}
@@ -0,0 +1,13 @@
fun test(x: Int) {
val f: Function<Int> = when (x) {
0 -> {
({ 0 })
}
1 -> {
(({ 1 }))
}
else -> {
((({ 2 })))
}
}
}