Introduce Variable: Do not delete original expression if its value is used in enclosing expression
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
fun a(x: Int) {
|
||||
val t = if (x > 0) <selection>x + x</selection> - 1 else x * x + 1
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun a(x: Int) {
|
||||
val t = if (x > 0) {
|
||||
val i = x + x
|
||||
i - 1
|
||||
} else x * x + 1
|
||||
}
|
||||
@@ -3,5 +3,6 @@ fun b() {
|
||||
a {it}
|
||||
a {
|
||||
val i = it
|
||||
i
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun a(x: Int) {
|
||||
val t = when {
|
||||
x > 0 -> <selection>x * x</selection> + 1
|
||||
x < 0 -> x + x
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
fun a(x: Int) {
|
||||
val t = when {
|
||||
x > 0 -> {
|
||||
val i = x * x
|
||||
i + 1
|
||||
}
|
||||
x < 0 -> x + x
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user