FIR IDE: AddWhenRemainingBranchFix
The fix reuses logic that is already available from FirWhenExhaustivenessTransformer to collect missing when branches. The current logic unfortunately uses hackyAllowRunningOnEdt to shorten the generated code.
This commit is contained in:
committed by
Ilya Kirillov
parent
6ec247b861
commit
63c65edda2
@@ -9,4 +9,3 @@ fun test(a: A) {
|
||||
|
||||
}
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -9,4 +9,3 @@ fun test(a: A) {
|
||||
is B -> TODO()
|
||||
}
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -11,4 +11,3 @@ fun test(a: A) {
|
||||
|
||||
}
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -11,4 +11,3 @@ fun test(a: A) {
|
||||
is B -> TODO()
|
||||
}
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -3,4 +3,3 @@
|
||||
fun test(b: Boolean) = wh<caret>en(b) {
|
||||
false -> 0
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -4,4 +4,3 @@ fun test(b: Boolean) = when(b) {
|
||||
false -> 0
|
||||
true -> TODO()
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -5,4 +5,3 @@ enum class Color { R, G, B }
|
||||
fun test(c: Color) = wh<caret>en(c) {
|
||||
Color.B -> 0xff
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -7,4 +7,3 @@ fun test(c: Color) = when(c) {
|
||||
Color.R -> TODO()
|
||||
Color.G -> TODO()
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -8,4 +8,3 @@ enum class FooEnum {
|
||||
fun test(foo: FooEnum?) = <caret>when (foo) {
|
||||
FooEnum.A -> "A"
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -14,4 +14,3 @@ fun test(foo: FooEnum?) = <caret>when (foo) {
|
||||
FooEnum.`null` -> TODO()
|
||||
null -> TODO()
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -6,4 +6,3 @@ enum class Color { R, G, B }
|
||||
fun test(c: Color) = wh<caret>en(c) {
|
||||
Color.B -> 0xff
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -8,4 +8,3 @@ fun test(c: Color) = when(c) {
|
||||
Color.R -> TODO()
|
||||
Color.G -> TODO()
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Add remaining branches" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
sealed class A
|
||||
class B : A()
|
||||
|
||||
fun test(a: A) {
|
||||
val i = w<caret>hen (a)
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Add remaining branches" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
sealed class A
|
||||
class B : A()
|
||||
|
||||
fun test(a: A) {
|
||||
val i = w<caret>hen (a) {
|
||||
is B -> TODO()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Add remaining branches" "false"
|
||||
// WITH_RUNTIME
|
||||
|
||||
sealed class A
|
||||
class B : A()
|
||||
|
||||
fun test(a: A) {
|
||||
val i = w<caret>hen (a)
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Add remaining branches" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
sealed class A
|
||||
class B : A()
|
||||
|
||||
fun test(a: A) {
|
||||
val i = w<caret>hen (a) {
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Add remaining branches" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
sealed class A
|
||||
class B : A()
|
||||
|
||||
fun test(a: A) {
|
||||
val i = w<caret>hen (a) {
|
||||
is B -> TODO()
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// "Add remaining branches" "false"
|
||||
// ACTION: Eliminate argument of 'when'
|
||||
// WITH_RUNTIME
|
||||
|
||||
sealed class A
|
||||
class B : A()
|
||||
|
||||
fun test(a: A) {
|
||||
val i = w<caret>hen (a) {
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Add remaining branches" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
sealed class A
|
||||
class B : A()
|
||||
|
||||
fun test(a: A) {
|
||||
val i = w<caret>hen (a
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Add remaining branches" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
sealed class A
|
||||
class B : A()
|
||||
|
||||
fun test(a: A) {
|
||||
val i = w<caret>hen (a) {
|
||||
is B -> TODO()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// "Add remaining branches" "false"
|
||||
// WITH_RUNTIME
|
||||
|
||||
sealed class A
|
||||
class B : A()
|
||||
|
||||
fun test(a: A) {
|
||||
<caret>when (a
|
||||
@@ -12,4 +12,3 @@ sealed class Variant {
|
||||
fun test(v: Variant?) = wh<caret>en(v) {
|
||||
Variant.Singleton -> "s"
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -15,4 +15,3 @@ fun test(v: Variant?) = when(v) {
|
||||
is Variant.Something -> TODO()
|
||||
null -> TODO()
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -13,4 +13,3 @@ object `null`: FooSealed()
|
||||
fun test(foo: FooSealed?) = <caret>when (foo) {
|
||||
A -> "A"
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
@@ -20,4 +20,3 @@ fun test(foo: FooSealed?) = <caret>when (foo) {
|
||||
is `true` -> TODO()
|
||||
null -> TODO()
|
||||
}
|
||||
/* IGNORE_FIR */
|
||||
|
||||
Reference in New Issue
Block a user