[FE 1.0] Fix reporting of non exhaustive when statement for whens with subject

^KT-48653 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-09-09 15:19:18 +03:00
parent f6ae6af741
commit 7a7672b0de
9 changed files with 145 additions and 4 deletions
@@ -0,0 +1,22 @@
// FIR_IDENTICAL
// LANGUAGE: +ProhibitNonExhaustiveWhenOnAlgebraicTypes
// ISSUE: KT-48653
sealed class Sealed {
object A : Sealed()
object B : Sealed()
}
fun functionReturningSealed(): Sealed = null!!
fun test_1() {
<!NO_ELSE_IN_WHEN!>when<!> (val result = functionReturningSealed()) {
is Sealed.A -> {}
}
}
fun test_2() {
val result2 = functionReturningSealed()
<!NO_ELSE_IN_WHEN!>when<!> (result2) {
is Sealed.A -> {}
}
}
@@ -0,0 +1,26 @@
package
public fun functionReturningSealed(): Sealed
public fun test_1(): kotlin.Unit
public fun test_2(): kotlin.Unit
public sealed class Sealed {
protected constructor Sealed()
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 A : Sealed {
private constructor A()
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 B : Sealed {
private constructor B()
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
}
}
@@ -0,0 +1,22 @@
// FIR_IDENTICAL
// LANGUAGE: -ProhibitNonExhaustiveWhenOnAlgebraicTypes
// ISSUE: KT-48653
sealed class Sealed {
object A : Sealed()
object B : Sealed()
}
fun functionReturningSealed(): Sealed = null!!
fun test_1() {
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (val result = functionReturningSealed()) {
is Sealed.A -> {}
}
}
fun test_2() {
val result2 = functionReturningSealed()
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (result2) {
is Sealed.A -> {}
}
}
@@ -0,0 +1,26 @@
package
public fun functionReturningSealed(): Sealed
public fun test_1(): kotlin.Unit
public fun test_2(): kotlin.Unit
public sealed class Sealed {
protected constructor Sealed()
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 A : Sealed {
private constructor A()
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 B : Sealed {
private constructor B()
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
}
}