[FE 1.0] Report NON_EXHAUSTIVE_WHEN_STATEMENT/NO_ELSE_IN_WHEN for when's on logical types
^KT-47709 In Progress
This commit is contained in:
committed by
teamcityserver
parent
85c7f386eb
commit
ef635f6a96
+1
-1
@@ -27,7 +27,7 @@ fun bar(a: Boolean, b: Boolean): Int {
|
||||
if (a) {
|
||||
x = 1
|
||||
}
|
||||
when (b) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (b) {
|
||||
false -> <!VAL_REASSIGNMENT!>x<!> = 3
|
||||
}
|
||||
return <!UNINITIALIZED_VARIABLE!>x<!>
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ fun bar(a: Boolean, b: Boolean): Int {
|
||||
if (a) {
|
||||
x = 1
|
||||
}
|
||||
when (b) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (b) {
|
||||
false -> x = 3
|
||||
}
|
||||
return <!UNINITIALIZED_VARIABLE!>x<!>
|
||||
|
||||
@@ -15,7 +15,7 @@ enum class X { A, B, C, D }
|
||||
|
||||
fun foo(arg: X): String {
|
||||
var res = "XXX"
|
||||
<!NON_EXHAUSTIVE_WHEN!>when<!> (arg) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (arg) {
|
||||
X.A -> res = "A"
|
||||
X.B -> res = "B"
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ object Last : S()
|
||||
fun use(s: String) = s
|
||||
|
||||
fun foo(s: S) {
|
||||
<!NON_EXHAUSTIVE_WHEN_ON_SEALED_CLASS!>when<!> (s) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (s) {
|
||||
First -> {}
|
||||
is Derived -> use(<!DEBUG_INFO_SMARTCAST!>s<!>.s)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 10
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 2
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 3
|
||||
*/
|
||||
|
||||
// Base for KT-6227
|
||||
enum class X { A, B, C, D }
|
||||
|
||||
fun foo(arg: X?): String {
|
||||
var res = "XXX"
|
||||
// Should we report something here? Probably not, null is not an enum entry
|
||||
when (arg) {
|
||||
X.A -> res = "A"
|
||||
X.B -> res = "B"
|
||||
X.C -> res = "C"
|
||||
X.D -> res = "D"
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
@@ -17,12 +16,11 @@ enum class X { A, B, C, D }
|
||||
|
||||
fun foo(arg: X?): String {
|
||||
var res = "XXX"
|
||||
// Should we report something here? Probably not, null is not an enum entry
|
||||
when (arg) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (arg) {
|
||||
X.A -> res = "A"
|
||||
X.B -> res = "B"
|
||||
X.C -> res = "C"
|
||||
X.D -> res = "D"
|
||||
}
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
// !LANGUAGE: -ProhibitNonExhaustiveWhenOnLogicalTypes
|
||||
|
||||
enum class SomeEnum {
|
||||
A, B
|
||||
}
|
||||
|
||||
sealed class Base {
|
||||
class A : Base()
|
||||
class B : Base()
|
||||
}
|
||||
|
||||
sealed interface IBase {
|
||||
interface A : IBase
|
||||
interface B : IBase
|
||||
}
|
||||
|
||||
// ------------------ not null ------------------
|
||||
|
||||
fun test_1(x: SomeEnum) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(x: Base) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: IBase) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4(x: Boolean) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ nullable ------------------
|
||||
|
||||
fun test_5(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
}
|
||||
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_6(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
}
|
||||
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_7(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
}
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_8(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
}
|
||||
|
||||
when (x) {
|
||||
true -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ with else ------------------
|
||||
|
||||
fun test_9(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_10(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_11(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_12(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ exhaustive ------------------
|
||||
|
||||
fun test_13(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_14(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_15(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_16(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// !LANGUAGE: -ProhibitNonExhaustiveWhenOnAlgebraicTypes
|
||||
|
||||
enum class SomeEnum {
|
||||
A, B
|
||||
}
|
||||
|
||||
sealed class Base {
|
||||
class A : Base()
|
||||
class B : Base()
|
||||
}
|
||||
|
||||
sealed interface IBase {
|
||||
interface A : IBase
|
||||
interface B : IBase
|
||||
}
|
||||
|
||||
// ------------------ not null ------------------
|
||||
|
||||
fun test_1(x: SomeEnum) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(x: Base) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: IBase) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4(x: Boolean) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
true -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ nullable ------------------
|
||||
|
||||
fun test_5(x: SomeEnum?) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
}
|
||||
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_6(x: Base?) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
}
|
||||
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_7(x: IBase?) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
}
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_8(x: Boolean?) {
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
}
|
||||
|
||||
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (x) {
|
||||
true -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ with else ------------------
|
||||
|
||||
fun test_9(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_10(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_11(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_12(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ exhaustive ------------------
|
||||
|
||||
fun test_13(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_14(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_15(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_16(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package
|
||||
|
||||
public fun test_1(/*0*/ x: SomeEnum): kotlin.Unit
|
||||
public fun test_10(/*0*/ x: Base?): kotlin.Unit
|
||||
public fun test_11(/*0*/ x: IBase?): kotlin.Unit
|
||||
public fun test_12(/*0*/ x: kotlin.Boolean?): kotlin.Unit
|
||||
public fun test_13(/*0*/ x: SomeEnum?): kotlin.Unit
|
||||
public fun test_14(/*0*/ x: Base?): kotlin.Unit
|
||||
public fun test_15(/*0*/ x: IBase?): kotlin.Unit
|
||||
public fun test_16(/*0*/ x: kotlin.Boolean?): kotlin.Unit
|
||||
public fun test_2(/*0*/ x: Base): kotlin.Unit
|
||||
public fun test_3(/*0*/ x: IBase): kotlin.Unit
|
||||
public fun test_4(/*0*/ x: kotlin.Boolean): kotlin.Unit
|
||||
public fun test_5(/*0*/ x: SomeEnum?): kotlin.Unit
|
||||
public fun test_6(/*0*/ x: Base?): kotlin.Unit
|
||||
public fun test_7(/*0*/ x: IBase?): kotlin.Unit
|
||||
public fun test_8(/*0*/ x: kotlin.Boolean?): kotlin.Unit
|
||||
public fun test_9(/*0*/ x: SomeEnum?): kotlin.Unit
|
||||
|
||||
public sealed class Base {
|
||||
protected constructor Base()
|
||||
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 final class A : Base {
|
||||
public 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 final class B : Base {
|
||||
public 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
|
||||
}
|
||||
}
|
||||
|
||||
public sealed interface IBase {
|
||||
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 interface A : IBase {
|
||||
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 interface B : IBase {
|
||||
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 final enum class SomeEnum : kotlin.Enum<SomeEnum> {
|
||||
enum entry A
|
||||
|
||||
enum entry B
|
||||
|
||||
private constructor SomeEnum()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: SomeEnum): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<SomeEnum!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): SomeEnum
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<SomeEnum>
|
||||
}
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
// !LANGUAGE: +ProhibitNonExhaustiveWhenOnLogicalTypes
|
||||
|
||||
enum class SomeEnum {
|
||||
A, B
|
||||
}
|
||||
|
||||
sealed class Base {
|
||||
class A : Base()
|
||||
class B : Base()
|
||||
}
|
||||
|
||||
sealed interface IBase {
|
||||
interface A : IBase
|
||||
interface B : IBase
|
||||
}
|
||||
|
||||
// ------------------ not null ------------------
|
||||
|
||||
fun test_1(x: SomeEnum) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(x: Base) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: IBase) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4(x: Boolean) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ nullable ------------------
|
||||
|
||||
fun test_5(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
}
|
||||
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_6(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
}
|
||||
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_7(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
}
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_8(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
}
|
||||
|
||||
when (x) {
|
||||
true -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ with else ------------------
|
||||
|
||||
fun test_9(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_10(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_11(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_12(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ exhaustive ------------------
|
||||
|
||||
fun test_13(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_14(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_15(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_16(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
// !LANGUAGE: +ProhibitNonExhaustiveWhenOnAlgebraicTypes
|
||||
|
||||
enum class SomeEnum {
|
||||
A, B
|
||||
}
|
||||
|
||||
sealed class Base {
|
||||
class A : Base()
|
||||
class B : Base()
|
||||
}
|
||||
|
||||
sealed interface IBase {
|
||||
interface A : IBase
|
||||
interface B : IBase
|
||||
}
|
||||
|
||||
// ------------------ not null ------------------
|
||||
|
||||
fun test_1(x: SomeEnum) {
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(x: Base) {
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(x: IBase) {
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_4(x: Boolean) {
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
true -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ nullable ------------------
|
||||
|
||||
fun test_5(x: SomeEnum?) {
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
}
|
||||
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
SomeEnum.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_6(x: Base?) {
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
}
|
||||
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
is Base.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_7(x: IBase?) {
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
}
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
is IBase.A -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_8(x: Boolean?) {
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
}
|
||||
|
||||
<!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
true -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ with else ------------------
|
||||
|
||||
fun test_9(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_10(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_11(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_12(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------ exhaustive ------------------
|
||||
|
||||
fun test_13(x: SomeEnum?) {
|
||||
when (x) {
|
||||
SomeEnum.A -> ""
|
||||
SomeEnum.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_14(x: Base?) {
|
||||
when (x) {
|
||||
is Base.A -> ""
|
||||
is Base.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_15(x: IBase?) {
|
||||
when (x) {
|
||||
is IBase.A -> ""
|
||||
is IBase.B -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
|
||||
fun test_16(x: Boolean?) {
|
||||
when (x) {
|
||||
true -> ""
|
||||
false -> ""
|
||||
null -> ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package
|
||||
|
||||
public fun test_1(/*0*/ x: SomeEnum): kotlin.Unit
|
||||
public fun test_10(/*0*/ x: Base?): kotlin.Unit
|
||||
public fun test_11(/*0*/ x: IBase?): kotlin.Unit
|
||||
public fun test_12(/*0*/ x: kotlin.Boolean?): kotlin.Unit
|
||||
public fun test_13(/*0*/ x: SomeEnum?): kotlin.Unit
|
||||
public fun test_14(/*0*/ x: Base?): kotlin.Unit
|
||||
public fun test_15(/*0*/ x: IBase?): kotlin.Unit
|
||||
public fun test_16(/*0*/ x: kotlin.Boolean?): kotlin.Unit
|
||||
public fun test_2(/*0*/ x: Base): kotlin.Unit
|
||||
public fun test_3(/*0*/ x: IBase): kotlin.Unit
|
||||
public fun test_4(/*0*/ x: kotlin.Boolean): kotlin.Unit
|
||||
public fun test_5(/*0*/ x: SomeEnum?): kotlin.Unit
|
||||
public fun test_6(/*0*/ x: Base?): kotlin.Unit
|
||||
public fun test_7(/*0*/ x: IBase?): kotlin.Unit
|
||||
public fun test_8(/*0*/ x: kotlin.Boolean?): kotlin.Unit
|
||||
public fun test_9(/*0*/ x: SomeEnum?): kotlin.Unit
|
||||
|
||||
public sealed class Base {
|
||||
protected constructor Base()
|
||||
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 final class A : Base {
|
||||
public 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 final class B : Base {
|
||||
public 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
|
||||
}
|
||||
}
|
||||
|
||||
public sealed interface IBase {
|
||||
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 interface A : IBase {
|
||||
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 interface B : IBase {
|
||||
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 final enum class SomeEnum : kotlin.Enum<SomeEnum> {
|
||||
enum entry A
|
||||
|
||||
enum entry B
|
||||
|
||||
private constructor SomeEnum()
|
||||
public final override /*1*/ /*fake_override*/ val name: kotlin.String
|
||||
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
|
||||
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
|
||||
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: SomeEnum): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
|
||||
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<SomeEnum!>!
|
||||
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
// Static members
|
||||
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): SomeEnum
|
||||
public final /*synthesized*/ fun values(): kotlin.Array<SomeEnum>
|
||||
}
|
||||
Reference in New Issue
Block a user