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:
committed by
Mikhail Glukhikh
parent
1072495001
commit
e30b9758f4
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user