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 @@
sealed class S
object First : S()
class Derived(val s: String) : S()
object Last : S()
fun use(s: String) = s
fun foo(s: S) {
<!NON_EXHAUSTIVE_WHEN_ON_SEALED_CLASS!>when<!> (s) {
First -> {}
is Derived -> use(<!DEBUG_INFO_SMARTCAST!>s<!>.s)
}
}
@@ -0,0 +1,33 @@
package
public fun foo(/*0*/ s: S): kotlin.Unit
public fun use(/*0*/ s: kotlin.String): kotlin.String
public final class Derived : S {
public constructor Derived(/*0*/ s: kotlin.String)
public final val s: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object First : S {
private constructor First()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object Last : S {
private constructor Last()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public sealed class S {
private constructor S()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}