Introduce action to add missing when branches on sealed class

Made via diagnostics NON_EXHAUSTIVE_WHEN_FOR_SEALED_CLASS
with INFO severity and quick-fix
So #KT-17580 Fixed
This commit is contained in:
fitermay
2017-05-10 22:56:06 -04:00
committed by Mikhail Glukhikh
parent 1072495001
commit e30b9758f4
12 changed files with 124 additions and 3 deletions
@@ -0,0 +1,16 @@
// "Add remaining branches" "true"
// ERROR: Unresolved reference: TODO
// ERROR: Unresolved reference: TODO
// ERROR: Unresolved reference: TODO
sealed class Variant {
object Singleton : Variant()
class Something(val x: Int) : Variant()
object Another : Variant()
}
fun test(v: Variant?) {
wh<caret>en(v) {
Variant.Singleton -> "s"
}
}
@@ -0,0 +1,19 @@
// "Add remaining branches" "true"
// ERROR: Unresolved reference: TODO
// ERROR: Unresolved reference: TODO
// ERROR: Unresolved reference: TODO
sealed class Variant {
object Singleton : Variant()
class Something(val x: Int) : Variant()
object Another : Variant()
}
fun test(v: Variant?) {
when(v) {
Variant.Singleton -> "s"
is Variant.Something -> TODO()
Variant.Another -> TODO()
null -> TODO()
}
}