Improve: add more cases for MoveVariableDeclarationIntoWhen
#KT-30499 Fixed
This commit is contained in:
+9
@@ -0,0 +1,9 @@
|
||||
fun test() = true
|
||||
|
||||
fun foo(): Int {
|
||||
val a<caret> = test()
|
||||
return when (a) {
|
||||
true -> 42
|
||||
else -> null
|
||||
} ?: 55
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun test() = true
|
||||
|
||||
fun foo(): Int {
|
||||
return when (test()) {
|
||||
true -> 42
|
||||
else -> null
|
||||
} ?: 55
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun test() = 42
|
||||
|
||||
fun foo() {
|
||||
val a<caret> = test()
|
||||
val b = when (a) {
|
||||
1 -> a
|
||||
else -> 24
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun test() = 42
|
||||
|
||||
fun foo() {
|
||||
val b = when (val a = test()) {
|
||||
1 -> a
|
||||
else -> 24
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fun test() = 42
|
||||
|
||||
fun foo(): Int {
|
||||
val a<caret> = test()
|
||||
return when (a) {
|
||||
1 -> a
|
||||
else -> 24
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun test() = 42
|
||||
|
||||
fun foo(): Int {
|
||||
return when (val a = test()) {
|
||||
1 -> a
|
||||
else -> 24
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fun test() = true
|
||||
|
||||
fun foo() {
|
||||
val a<caret> = test()
|
||||
val b = !when (a) {
|
||||
true -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
fun test() = true
|
||||
|
||||
fun foo() {
|
||||
val b = !when (test()) {
|
||||
true -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
// PROBLEM: none
|
||||
fun test() = true
|
||||
|
||||
fun foo(): Int {
|
||||
val a<caret> = test()
|
||||
return null ?: when (a) {
|
||||
true -> 42
|
||||
else -> 5
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user