WhenWithOnlyElse: don't remove when subject variable if needed
#KT-30975 Fixed
This commit is contained in:
committed by
Dmitry Gridin
parent
7f1d30058a
commit
e955dcfc14
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
val x = when (val a = create()) {
|
||||
else -> {
|
||||
use(a, a)
|
||||
}
|
||||
}<caret>
|
||||
}
|
||||
|
||||
fun create(): String = ""
|
||||
|
||||
fun use(s: String, t: String) {}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
val x = <caret>run {
|
||||
val a = create()
|
||||
use(a, a)
|
||||
}
|
||||
}
|
||||
|
||||
fun create(): String = ""
|
||||
|
||||
fun use(s: String, t: String) {}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
val x = when (val a = create()) {
|
||||
else -> {
|
||||
use("")
|
||||
}
|
||||
}<caret>
|
||||
}
|
||||
|
||||
fun create(): String = ""
|
||||
|
||||
fun use(s: String) {}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
val x = <caret>run {
|
||||
val a = create()
|
||||
use("")
|
||||
}
|
||||
}
|
||||
|
||||
fun create(): String = ""
|
||||
|
||||
fun use(s: String) {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
val x = when (val a = 42) {
|
||||
else -> {
|
||||
use("")
|
||||
}
|
||||
}<caret>
|
||||
}
|
||||
|
||||
fun use(s: String) {}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
val x = <caret>run {
|
||||
use("")
|
||||
}
|
||||
}
|
||||
|
||||
fun use(s: String) {}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
val x = when (val a = create()) {
|
||||
else -> {
|
||||
use(a)
|
||||
}
|
||||
}<caret>
|
||||
}
|
||||
|
||||
fun create(): String = ""
|
||||
|
||||
fun use(s: String) {}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_RUNTIME
|
||||
fun test() {
|
||||
val x = <caret>run {
|
||||
use(create())
|
||||
}
|
||||
}
|
||||
|
||||
fun create(): String = ""
|
||||
|
||||
fun use(s: String) {}
|
||||
Reference in New Issue
Block a user