Remove braces: add parentheses to if-else inside expression

So #KT-18308 Fixed
This commit is contained in:
Toshiaki Kameyama
2017-11-30 03:16:50 +03:00
committed by Mikhail Glukhikh
parent 19e38bbc72
commit 44c15d8311
8 changed files with 79 additions and 1 deletions
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun test(b: Boolean) {
val list1 = mutableListOf(1)
val list2 = mutableListOf(2)
if (b) list1 else <caret>{list2}.add(3)
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun test(b: Boolean) {
val list1 = mutableListOf(1)
val list2 = mutableListOf(2)
(if (b) list1 else list2).add(3)
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun test(b: Boolean) {
val list1 = mutableListOf(1)
val list2 = mutableListOf(2)
if (b) <caret>{list1} else {list2}.add(3)
}
@@ -0,0 +1,7 @@
// WITH_RUNTIME
fun test(b: Boolean) {
val list1 = mutableListOf(1)
val list2 = mutableListOf(2)
if (b) list1 else {list2}.add(3)
}
@@ -0,0 +1,12 @@
// WITH_RUNTIME
fun test(b: Boolean) {
val list1 = mutableListOf(1)
val list2 = mutableListOf(2)
when {
b -> list1
else -> <caret>{
list2
}
}.add(3)
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
fun test(b: Boolean) {
val list1 = mutableListOf(1)
val list2 = mutableListOf(2)
when {
b -> list1
else -> list2
}.add(3)
}