Add multilevel sections support and corresponding renaming

This commit is contained in:
victor.petukhov
2018-09-24 23:27:06 +03:00
parent 2c313e12e5
commit 84dc28374c
140 changed files with 946 additions and 943 deletions
+4 -4
View File
@@ -35,7 +35,7 @@ A comment with meta information has the following format:
/* /*
KOTLIN SPEC TEST (<POSITIVE|NEGATIVE>) KOTLIN SPEC TEST (<POSITIVE|NEGATIVE>)
SECTION: <sectionName> SECTIONS: <sectionNames{,}>
PARAGRAPH: <paragraphNumber> PARAGRAPH: <paragraphNumber>
SENTENCE: [<setenceNumber>] <setence> SENTENCE: [<setenceNumber>] <setence>
NUMBER: <testNumber> NUMBER: <testNumber>
@@ -47,7 +47,7 @@ Example:
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 2 PARAGRAPH: 2
SENTENCE: [3] When expression has two different forms: with bound value and without it. SENTENCE: [3] When expression has two different forms: with bound value and without it.
NUMBER: 1 NUMBER: 1
@@ -93,7 +93,7 @@ During the test run, the following information is displayed for each test:
``` ```
DIAGNOSTICS <POSITIVE|NEGATIVE> SPEC TEST DIAGNOSTICS <POSITIVE|NEGATIVE> SPEC TEST
SECTION: <sectionName> (paragraph: <paragraphNumber>) SECTIONS: <sectionName> (paragraph: <paragraphNumber>)
SENTENCE <sentenceNumber>: <sentence> SENTENCE <sentenceNumber>: <sentence>
TEST NUMBER: <testNumber> TEST NUMBER: <testNumber>
TEST CASES: <casesNumber> TEST CASES: <casesNumber>
@@ -103,7 +103,7 @@ DIAGNOSTICS: <diagnosticSeverities> | <diagnostics>
Example: Example:
``` ```
DIAGNOSTICS NEGATIVE SPEC TEST DIAGNOSTICS NEGATIVE SPEC TEST
SECTION: when-expression (paragraph: 3) SECTIONS: when-expression (paragraph: 3)
SENTENCE 1: SENTENCE 1:
TEST NUMBER: 1 TEST NUMBER: 1
NUMBER OF TEST CASES: 3 NUMBER OF TEST CASES: 3
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [1] It has an else entry; SENTENCE: [1] It has an else entry;
NUMBER: 1 NUMBER: 1
@@ -9,15 +9,15 @@
*/ */
// CASE DESCRIPTION: Checking for not exhaustive 'when' (several branches). // CASE DESCRIPTION: Checking for not exhaustive 'when' (several branches).
fun case_1(value: Int): String = <!NO_ELSE_IN_WHEN!>when<!> { fun case_1(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> {
value == 1 -> "" value_1 == 1 -> ""
value == 2 -> "" value_1 == 2 -> ""
value == 3 -> "" value_1 == 3 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' (one branch). // CASE DESCRIPTION: Checking for not exhaustive 'when' (one branch).
fun case_2(value: Int): String = <!NO_ELSE_IN_WHEN!>when<!> { fun case_2(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> {
value == 1 -> "" value_1 == 1 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' (no branches). // CASE DESCRIPTION: Checking for not exhaustive 'when' (no branches).
@@ -3,7 +3,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [1] It has an else entry; SENTENCE: [1] It has an else entry;
NUMBER: 2 NUMBER: 2
@@ -11,16 +11,16 @@
*/ */
// CASE DESCRIPTION: Checking for not exhaustive 'when' (several branches). // CASE DESCRIPTION: Checking for not exhaustive 'when' (several branches).
fun case_1(value: Int): String = <!NO_ELSE_IN_WHEN!>when<!> (value) { fun case_1(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
1 -> "" 1 -> ""
2 -> "" 2 -> ""
3 -> "" 3 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' (one branch). // CASE DESCRIPTION: Checking for not exhaustive 'when' (one branch).
fun case_2(value: Int): String = <!NO_ELSE_IN_WHEN!>when<!> (value) { fun case_2(value_1: Int): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
1 -> "" 1 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' (no branches). // CASE DESCRIPTION: Checking for not exhaustive 'when' (no branches).
fun case_3(value: Int): Int = <!NO_ELSE_IN_WHEN!>when<!> (value) {} fun case_3(value_1: Int): Int = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {}
@@ -3,7 +3,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both: SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both:
NUMBER: 1 NUMBER: 1
@@ -11,22 +11,22 @@
*/ */
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (with only true branch). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (with only true branch).
fun case_1(value: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_1(value_1: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
true -> "" true -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (with only false branch). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (with only false branch).
fun case_2(value: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_2(value_1: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
false -> "" false -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (no branches). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean value (no branches).
fun case_3(value: Boolean): Int = <!NO_ELSE_IN_WHEN!>when<!>(value) { } fun case_3(value_1: Boolean): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
// CASE DESCRIPTION: Checking for not exhaustive 'when' without bound value on the Boolean. // CASE DESCRIPTION: Checking for not exhaustive 'when' without bound value on the Boolean.
fun case_4(value: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!> { fun case_4(value_1: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!> {
value == true -> "" value_1 == true -> ""
value == false -> "" value_1 == false -> ""
} }
/* /*
@@ -34,11 +34,11 @@ fun case_4(value: Boolean): String = <!NO_ELSE_IN_WHEN!>when<!> {
DISCUSSION: maybe use const propagation here? DISCUSSION: maybe use const propagation here?
ISSUES: KT-25265 ISSUES: KT-25265
*/ */
fun case_5(value: Boolean): String { fun case_5(value_1: Boolean): String {
val trueValue = true val trueValue = true
val falseValue = false val falseValue = false
return <!NO_ELSE_IN_WHEN!>when<!> (value) { return <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
trueValue -> "" trueValue -> ""
falseValue -> "" falseValue -> ""
} }
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [6] The bound expression is of a sealed class type and all its possible subtypes are covered using type test conditions of this expression; SENTENCE: [6] The bound expression is of a sealed class type and all its possible subtypes are covered using type test conditions of this expression;
NUMBER: 1 NUMBER: 1
@@ -12,46 +12,46 @@
*/ */
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking).
fun case_1(value: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_1(value_1: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedChild1 -> "" is _SealedChild1 -> ""
is _SealedChild2 -> "" is _SealedChild2 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking with enumeration). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking with enumeration).
fun case_2(value: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_2(value_1: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedChild1, is _SealedChild2 -> "" is _SealedChild1, is _SealedChild2 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking and equality with object). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking and equality with object).
fun case_3(value: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_3(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
_SealedMixedChildObject1 -> "" _SealedMixedChildObject1 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking and equality with object with enumeration). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking and equality with object with enumeration).
fun case_4(value: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_4(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_SealedMixedChildObject1, is _SealedMixedChild2, is _SealedMixedChild1 -> "" _SealedMixedChildObject1, is _SealedMixedChild2, is _SealedMixedChild1 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking).
fun case_5(value: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_5(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> "" is _SealedMixedChild3 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class with several subtypes (no branches). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class with several subtypes (no branches).
fun case_6(value: _SealedClassMixed): Int = <!NO_ELSE_IN_WHEN!>when<!>(value) { } fun case_6(value_1: _SealedClassMixed): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class with one subtype (no branches). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class with one subtype (no branches).
fun case_7(value: _SealedClassSingleWithObject): Int = <!NO_ELSE_IN_WHEN!>when<!>(value) { } fun case_7(value_1: _SealedClassSingleWithObject): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty sealed class (without subtypes). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty sealed class (without subtypes).
fun case_8(value: _SealedClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value) { } fun case_8(value_1: _SealedClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the not sealed class. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the not sealed class.
fun case_9(value: Number): String = <!NO_ELSE_IN_WHEN!>when<!> (value) { fun case_9(value_1: Number): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
is Byte -> "" is Byte -> ""
is Double -> "" is Double -> ""
is Float -> "" is Float -> ""
@@ -64,19 +64,19 @@ fun case_9(value: Number): String = <!NO_ELSE_IN_WHEN!>when<!> (value) {
CASE DESCRIPTION: Checking for not exhaustive 'when' on the Any. CASE DESCRIPTION: Checking for not exhaustive 'when' on the Any.
DISCUSSION: maybe make exhaustive without else? DISCUSSION: maybe make exhaustive without else?
*/ */
fun case_10(value: Any): String = <!NO_ELSE_IN_WHEN!>when<!> (value) { fun case_10(value_1: Any): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
<!USELESS_IS_CHECK!>is Any<!> -> "" <!USELESS_IS_CHECK!>is Any<!> -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' without bound value on the Sealed class with all subtypes covered. // CASE DESCRIPTION: Checking for not exhaustive 'when' without bound value on the Sealed class with all subtypes covered.
fun case_11(value: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!> { fun case_11(value_1: _SealedClass): String = <!NO_ELSE_IN_WHEN!>when<!> {
value is _SealedChild1 -> "" value_1 is _SealedChild1 -> ""
value is _SealedChild2 -> "" value_1 is _SealedChild2 -> ""
value is _SealedChild3 -> "" value_1 is _SealedChild3 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the sealed class (type checking).
fun case_12(value: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_12(value_1: _SealedClassMixed): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> "" is _SealedMixedChild3 -> ""
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions; SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions;
NUMBER: 1 NUMBER: 1
@@ -12,37 +12,37 @@
*/ */
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (not all values). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (not all values).
fun case_1(value: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_1(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.SOUTH -> "" _EnumClass.SOUTH -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (not all values with enumerations). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (not all values with enumerations).
fun case_2(value: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_2(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST, _EnumClass.SOUTH, _EnumClass.NORTH -> "" _EnumClass.EAST, _EnumClass.SOUTH, _EnumClass.NORTH -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (one branch). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum (one branch).
fun case_3(value: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_3(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum with several values (no branches). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum with several values (no branches).
fun case_4(value: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { } fun case_4(value_1: _EnumClass): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum with one value (no branches). // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum with one value (no branches).
fun case_5(value: _EnumClassSingle): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { } fun case_5(value_1: _EnumClassSingle): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
/* /*
CASE DESCRIPTION: Checking for not exhaustive 'when' with all Enum values covered, but using variable. CASE DESCRIPTION: Checking for not exhaustive 'when' with all Enum values covered, but using variable.
DISCUSSION: maybe use const propagation here? DISCUSSION: maybe use const propagation here?
ISSUES: KT-25265 ISSUES: KT-25265
*/ */
fun case_6(value: _EnumClass): String { fun case_6(value_1: _EnumClass): String {
val west = _EnumClass.WEST val west = _EnumClass.WEST
return <!NO_ELSE_IN_WHEN!>when<!> (value) { return <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.SOUTH -> "" _EnumClass.SOUTH -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
@@ -51,4 +51,4 @@ fun case_6(value: _EnumClass): String {
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty enum class. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the empty enum class.
fun case_7(value: _EnumClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value) { } fun case_7(value_1: _EnumClassEmpty): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) { }
@@ -3,24 +3,24 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 1 NUMBER: 1
DESCRIPTION: Checking for not exhaustive 'when' on the nullable Boolean. DESCRIPTION: Checking for not exhaustive 'when' on the nullable Boolean.
*/ */
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean without null-check branch. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean without null-check branch.
fun case_1(value: Boolean?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_1(value_1: Boolean?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
true -> "" true -> ""
false -> "" false -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean with null-check branch, but all possible values not covered. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean with null-check branch, but all possible values not covered.
fun case_2(value: Boolean?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_2(value_1: Boolean?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
true -> "" true -> ""
null -> "" null -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean without branches. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Boolean without branches.
fun case_3(value: Boolean?): Int = <!NO_ELSE_IN_WHEN!>when<!>(value) { } fun case_3(value_1: Boolean?): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) { }
@@ -4,22 +4,22 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 2 NUMBER: 2
DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed classes (and several checks for not sealed). DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed classes (and several checks for not sealed).
*/ */
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch.
fun case_1(value: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_1(value_1: _SealedClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedChild1 -> "" is _SealedChild1 -> ""
is _SealedChild2 -> "" is _SealedChild2 -> ""
is _SealedChild3 -> "" is _SealedChild3 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with mixed checks (type and object check) and null-check branch. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with mixed checks (type and object check) and null-check branch.
fun case_2(value: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_2(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
_SealedMixedChildObject1 -> "" _SealedMixedChildObject1 -> ""
@@ -27,12 +27,12 @@ fun case_2(value: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with enumeration mixed checks (type and object check) and null-check branch. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with enumeration mixed checks (type and object check) and null-check branch.
fun case_3(value: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_3(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null, is _SealedMixedChild1, is _SealedMixedChild2, _SealedMixedChildObject1 -> "" null, is _SealedMixedChild1, is _SealedMixedChild2, _SealedMixedChildObject1 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with all subtypes and objects covered without null-check branch. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with all subtypes and objects covered without null-check branch.
fun case_4(value: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_4(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> "" is _SealedMixedChild3 -> ""
@@ -42,17 +42,17 @@ fun case_4(value: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch and all subtypes covered, but objects not covered. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch and all subtypes covered, but objects not covered.
fun case_5(value: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_5(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> "" is _SealedMixedChild3 -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without branches. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without branches.
fun case_6(value: _SealedClassMixed?): Int = <!NO_ELSE_IN_WHEN!>when<!>(value) {} fun case_6(value_1: _SealedClassMixed?): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with null-check branch and all subtypes covered, but objects not covered. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class with null-check branch and all subtypes covered, but objects not covered.
fun case_7(value: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_7(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2-> "" is _SealedMixedChild2-> ""
is _SealedMixedChild3 -> "" is _SealedMixedChild3 -> ""
@@ -60,7 +60,7 @@ fun case_7(value: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch and only object covered. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable sealed class without null-check branch and only object covered.
fun case_8(value: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_8(value_1: _SealedClassMixed?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_SealedMixedChildObject1 -> "" _SealedMixedChildObject1 -> ""
} }
@@ -77,7 +77,7 @@ fun case_9(value: _SealedClassEmpty?): String = <!NO_ELSE_IN_WHEN!>when<!> (valu
CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable Any. CASE DESCRIPTION: Checking for not exhaustive 'when' on the nullable Any.
DISCUSSION: maybe make exhaustive without else? DISCUSSION: maybe make exhaustive without else?
*/ */
fun case_10(value: Any?): String = <!NO_ELSE_IN_WHEN!>when<!> (value) { fun case_10(value_1: Any?): String = <!NO_ELSE_IN_WHEN!>when<!> (value_1) {
is Any -> "" is Any -> ""
null -> "" null -> ""
} }
@@ -4,15 +4,15 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 3 NUMBER: 3
DESCRIPTION: Checking for not exhaustive 'when' on the nullable enums. DESCRIPTION: Checking for not exhaustive 'when' on the nullable enums.
*/ */
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class without null-check branch. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class without null-check branch.
fun case_1(value: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_1(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.SOUTH -> "" _EnumClass.SOUTH -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
@@ -20,7 +20,7 @@ fun case_1(value: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) {
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class with null-check branch, but all possible values not covered. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class with null-check branch, but all possible values not covered.
fun case_2(value: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_2(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.SOUTH -> "" _EnumClass.SOUTH -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
@@ -28,20 +28,20 @@ fun case_2(value: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) {
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class with null-check branch, but all possible values not covered. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class with null-check branch, but all possible values not covered.
fun case_3(value: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_3(value_1: _EnumClass?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClass.EAST, null, _EnumClass.SOUTH, _EnumClass.NORTH -> "" _EnumClass.EAST, null, _EnumClass.SOUTH, _EnumClass.NORTH -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class without branches. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class without branches.
fun case_4(value: _EnumClassSingle): Int = <!NO_ELSE_IN_WHEN!>when<!>(value) {} fun case_4(value_1: _EnumClassSingle): Int = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {}
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class (with only one value) without null-check branch. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class (with only one value) without null-check branch.
fun case_5(value: _EnumClassSingle?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_5(value_1: _EnumClassSingle?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
_EnumClassSingle.EVERYTHING -> "" _EnumClassSingle.EVERYTHING -> ""
} }
// CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class (with only one value) with null-check branch, but value not covered. // CASE DESCRIPTION: Checking for not exhaustive 'when' on the Enum class (with only one value) with null-check branch, but value not covered.
fun case_6(value: _EnumClassSingle?): String = <!NO_ELSE_IN_WHEN!>when<!>(value) { fun case_6(value_1: _EnumClassSingle?): String = <!NO_ELSE_IN_WHEN!>when<!>(value_1) {
null -> "" null -> ""
} }
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [1] It has an else entry; SENTENCE: [1] It has an else entry;
NUMBER: 1 NUMBER: 1
@@ -9,11 +9,11 @@
*/ */
// CASE DESCRIPTION: Checking for exhaustive 'when' (several value check branches and 'else' branch). // CASE DESCRIPTION: Checking for exhaustive 'when' (several value check branches and 'else' branch).
fun case_1(value: Int): String = when { fun case_1(value_1: Int): String = when {
value == 0 -> "" value_1 == 0 -> ""
value > 0 && value <= 10 -> "" value_1 > 0 && value_1 <= 10 -> ""
value > 10 && value <= 100 -> "" value_1 > 10 && value_1 <= 100 -> ""
value > 100 -> "" value_1 > 100 -> ""
else -> "" else -> ""
} }
@@ -3,7 +3,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [1] It has an else entry; SENTENCE: [1] It has an else entry;
NUMBER: 2 NUMBER: 2
@@ -11,7 +11,7 @@
*/ */
// CASE DESCRIPTION: Checking for exhaustive 'when' (several branches). // CASE DESCRIPTION: Checking for exhaustive 'when' (several branches).
fun case_1(value: Int): String = when (value) { fun case_1(value_1: Int): String = when (value_1) {
0 -> "" 0 -> ""
1 -> "" 1 -> ""
2 -> "" 2 -> ""
@@ -20,14 +20,14 @@ fun case_1(value: Int): String = when (value) {
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (value check branch and 'else' branch). // CASE DESCRIPTION: Checking for exhaustive 'when' (value check branch and 'else' branch).
fun case_2(value: Boolean): String = when (value) { fun case_2(value_1: Boolean): String = when (value_1) {
true -> "" true -> ""
else -> "" else -> ""
} }
/* /*
CASE DESCRIPTION: Checking for exhaustive 'when' with constant bound value (value check branch and 'else' branch). CASE DESCRIPTION: Checking for exhaustive 'when' with constant bound value (value check branch and 'else' branch).
NOTE: for potential bound value constant analysys. NOTE: for potential bound value constant analysis.
*/ */
fun case_3(): String = when (true) { fun case_3(): String = when (true) {
true -> "" true -> ""
@@ -35,6 +35,6 @@ fun case_3(): String = when (true) {
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (only 'else' branch). // CASE DESCRIPTION: Checking for exhaustive 'when' (only 'else' branch).
fun case_4(value: Int): String = when(value) { fun case_4(value_1: Int): String = when(value_1) {
else -> "" else -> ""
} }
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [1] It has an else entry; SENTENCE: [1] It has an else entry;
NUMBER: 3 NUMBER: 3
@@ -12,7 +12,7 @@
*/ */
// CASE DESCRIPTION: Checking for redundant 'else' branch (all enum values covered). // CASE DESCRIPTION: Checking for redundant 'else' branch (all enum values covered).
fun case_1(value: _EnumClass): String = when (value) { fun case_1(value_1: _EnumClass): String = when (value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
_EnumClass.SOUTH -> "" _EnumClass.SOUTH -> ""
@@ -21,7 +21,7 @@ fun case_1(value: _EnumClass): String = when (value) {
} }
// CASE DESCRIPTION: Checking for redundant 'else' branch (all enum values and null value covered). // CASE DESCRIPTION: Checking for redundant 'else' branch (all enum values and null value covered).
fun case_2(value: _EnumClass?): String = when (value) { fun case_2(value_1: _EnumClass?): String = when (value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
_EnumClass.SOUTH -> "" _EnumClass.SOUTH -> ""
@@ -31,14 +31,14 @@ fun case_2(value: _EnumClass?): String = when (value) {
} }
// CASE DESCRIPTION: Checking for redundant 'else' branch (both boolean value covered). // CASE DESCRIPTION: Checking for redundant 'else' branch (both boolean value covered).
fun case_3(value: Boolean): String = when (value) { fun case_3(value_1: Boolean): String = when (value_1) {
true -> "" true -> ""
false -> "" false -> ""
<!REDUNDANT_ELSE_IN_WHEN!>else<!> -> "" <!REDUNDANT_ELSE_IN_WHEN!>else<!> -> ""
} }
// CASE DESCRIPTION: Checking for redundant 'else' branch (both boolean value and null value covered). // CASE DESCRIPTION: Checking for redundant 'else' branch (both boolean value and null value covered).
fun case_4(value: Boolean?): String = when (value) { fun case_4(value_1: Boolean?): String = when (value_1) {
true -> "" true -> ""
false -> "" false -> ""
null -> "" null -> ""
@@ -46,7 +46,7 @@ fun case_4(value: Boolean?): String = when (value) {
} }
// CASE DESCRIPTION: Checking for redundant 'else' branch (all sealed class subtypes covered). // CASE DESCRIPTION: Checking for redundant 'else' branch (all sealed class subtypes covered).
fun case_5(value: _SealedClass): String = when (value) { fun case_5(value_1: _SealedClass): String = when (value_1) {
is _SealedChild1 -> "" is _SealedChild1 -> ""
is _SealedChild2 -> "" is _SealedChild2 -> ""
is _SealedChild3 -> "" is _SealedChild3 -> ""
@@ -54,7 +54,7 @@ fun case_5(value: _SealedClass): String = when (value) {
} }
// CASE DESCRIPTION: Checking for redundant 'else' branch (all sealed class subtypes and null value covered). // CASE DESCRIPTION: Checking for redundant 'else' branch (all sealed class subtypes and null value covered).
fun case_6(value: _SealedClass?): String = when (value) { fun case_6(value_1: _SealedClass?): String = when (value_1) {
is _SealedChild1 -> "" is _SealedChild1 -> ""
is _SealedChild2 -> "" is _SealedChild2 -> ""
is _SealedChild3 -> "" is _SealedChild3 -> ""
@@ -63,13 +63,13 @@ fun case_6(value: _SealedClass?): String = when (value) {
} }
// CASE DESCRIPTION: Checking for redundant 'else' branch (sealed class itself covered). // CASE DESCRIPTION: Checking for redundant 'else' branch (sealed class itself covered).
fun case_7(value: _SealedClassSingle): String = when (value) { fun case_7(value_1: _SealedClassSingle): String = when (value_1) {
<!USELESS_IS_CHECK!>is _SealedClassSingle<!> -> "" <!USELESS_IS_CHECK!>is _SealedClassSingle<!> -> ""
<!REDUNDANT_ELSE_IN_WHEN!>else<!> -> "" <!REDUNDANT_ELSE_IN_WHEN!>else<!> -> ""
} }
// CASE DESCRIPTION: Checking for redundant 'else' branch (sealed class itself and null value covered). // CASE DESCRIPTION: Checking for redundant 'else' branch (sealed class itself and null value covered).
fun case_8(value: _SealedClassSingle?): String = when (value) { fun case_8(value_1: _SealedClassSingle?): String = when (value_1) {
is _SealedClassSingle -> "" is _SealedClassSingle -> ""
null -> "" null -> ""
<!REDUNDANT_ELSE_IN_WHEN!>else<!> -> "" <!REDUNDANT_ELSE_IN_WHEN!>else<!> -> ""
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both: SENTENCE: [3] The bound expression is of type kotlin.Boolean and the conditions contain both:
NUMBER: 1 NUMBER: 1
@@ -9,13 +9,13 @@
*/ */
// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean value covered).
fun case_1(value: Boolean): String = when (value) { fun case_1(value_1: Boolean): String = when (value_1) {
true -> "" true -> ""
false -> "" false -> ""
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean value as complex expression covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean value as complex expression covered).
fun case_2(value: Boolean): String = when (value) { fun case_2(value_1: Boolean): String = when (value_1) {
true && false && ((true || false)) || true && !!!false && !!!true -> "" true && false && ((true || false)) || true && !!!false && !!!true -> ""
true && false && ((true || false)) || true && !!!false -> "" true && false && ((true || false)) || true && !!!false -> ""
} }
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [6] The bound valueession is of a sealed class type and all its possible subtypes are covered using type test conditions of this valueession; SENTENCE: [6] The bound valueession is of a sealed class type and all its possible subtypes are covered using type test conditions of this valueession;
NUMBER: 1 NUMBER: 1
@@ -12,33 +12,33 @@
*/ */
// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes covered).
fun case_1(value: _SealedClass): Int = when (value) { fun case_1(value_1: _SealedClass): Int = when (value_1) {
is _SealedChild1 -> <!DEBUG_INFO_SMARTCAST!>value<!>.number is _SealedChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.number
is _SealedChild2 -> <!DEBUG_INFO_SMARTCAST!>value<!>.e1 + <!DEBUG_INFO_SMARTCAST!>value<!>.e2 is _SealedChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.e1 + <!DEBUG_INFO_SMARTCAST!>value_1<!>.e2
is _SealedChild3 -> <!DEBUG_INFO_SMARTCAST!>value<!>.m1 + <!DEBUG_INFO_SMARTCAST!>value<!>.m2 is _SealedChild3 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1 + <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (single sealed class subtypes covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (single sealed class subtypes covered).
fun case_2(value: _SealedClass): String = when (value) { fun case_2(value_1: _SealedClass): String = when (value_1) {
<!USELESS_IS_CHECK!>is _SealedClass<!> -> "" <!USELESS_IS_CHECK!>is _SealedClass<!> -> ""
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes with methods covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes with methods covered).
fun case_3(value: _SealedClassWithMethods): String = when (value) { fun case_3(value_1: _SealedClassWithMethods): String = when (value_1) {
is _SealedWithMethodsChild1 -> <!DEBUG_INFO_SMARTCAST!>value<!>.m1() is _SealedWithMethodsChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1()
is _SealedWithMethodsChild2 -> <!DEBUG_INFO_SMARTCAST!>value<!>.m2() is _SealedWithMethodsChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2()
is _SealedWithMethodsChild3 -> <!DEBUG_INFO_SMARTCAST!>value<!>.m3() is _SealedWithMethodsChild3 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m3()
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (all objects covered using implicit equality operator). // CASE DESCRIPTION: Checking for exhaustive 'when' (all objects covered using implicit equality operator).
fun case_4(value: _SealedClassWithObjects): String = when (value) { fun case_4(value_1: _SealedClassWithObjects): String = when (value_1) {
_SealedWithObjectsChild1 -> "" _SealedWithObjectsChild1 -> ""
_SealedWithObjectsChild2 -> "" _SealedWithObjectsChild2 -> ""
_SealedWithObjectsChild3 -> "" _SealedWithObjectsChild3 -> ""
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects covered).
fun case_5(value: _SealedClassMixed): String = when (value) { fun case_5(value_1: _SealedClassMixed): String = when (value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> "" is _SealedMixedChild3 -> ""
@@ -51,7 +51,7 @@ fun case_5(value: _SealedClassMixed): String = when (value) {
CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects (using type checking operator) covered). CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects (using type checking operator) covered).
DISCUSSION: is it correct that objects can be checked using the type checking operator? DISCUSSION: is it correct that objects can be checked using the type checking operator?
*/ */
fun case_6(value: _SealedClassMixed): String = when (value) { fun case_6(value_1: _SealedClassMixed): String = when (value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> "" is _SealedMixedChild3 -> ""
@@ -61,6 +61,6 @@ fun case_6(value: _SealedClassMixed): String = when (value) {
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' on the empty sealed class (without subtypes). // CASE DESCRIPTION: Checking for exhaustive 'when' on the empty sealed class (without subtypes).
fun case_7(value: _SealedClassEmpty): String = when (value) { fun case_7(value_1: _SealedClassEmpty): String = when (value_1) {
else -> "" else -> ""
} }
@@ -3,7 +3,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions; SENTENCE: [7] The bound expression is of an Enum classes type and all enumerated values are checked for equality using constant conditions;
NUMBER: 1 NUMBER: 1
@@ -19,6 +19,6 @@ fun case_1(dir: _EnumClass): String = when (dir) {
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (single enum value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (single enum value covered).
fun case_2(value: _EnumClassSingle): String = when (value) { fun case_2(value_1: _EnumClassSingle): String = when (value_1) {
_EnumClassSingle.EVERYTHING -> "" _EnumClassSingle.EVERYTHING -> ""
} }
@@ -1,22 +1,22 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 1 NUMBER: 1
DESCRIPTION: Check when exhaustive when boolean values are checked and contains a null check. DESCRIPTION: Check when exhaustive when boolean values are checked and contains a null check.
*/ */
// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean values and null value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean values and null value covered).
fun case_1(value: Boolean?): String = when (value) { fun case_1(value_1: Boolean?): String = when (value_1) {
true -> "" true -> ""
false -> "" false -> ""
null -> "" null -> ""
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean values as complex expressions and null value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (both boolean values as complex expressions and null value covered).
fun case_2(value: Boolean?): String = when (value) { fun case_2(value_1: Boolean?): String = when (value_1) {
true && false && ((true || false)) || true && !!!false && !!!true -> "" true && false && ((true || false)) || true && !!!false && !!!true -> ""
true && false && ((true || false)) || true && !!!false -> "" true && false && ((true || false)) || true && !!!false -> ""
null -> "" null -> ""
@@ -3,7 +3,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 2 NUMBER: 2
@@ -11,7 +11,7 @@
*/ */
// CASE DESCRIPTION: Checking for exhaustive 'when' (both enum values and null value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (both enum values and null value covered).
fun case_1(dir: _EnumClass?): String = when (dir) { fun case_1(value_1: _EnumClass?): String = when (value_1) {
_EnumClass.EAST -> "" _EnumClass.EAST -> ""
_EnumClass.NORTH -> "" _EnumClass.NORTH -> ""
_EnumClass.SOUTH -> "" _EnumClass.SOUTH -> ""
@@ -20,7 +20,7 @@ fun case_1(dir: _EnumClass?): String = when (dir) {
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (single enum value and null value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (single enum value and null value covered).
fun case_2(value: _EnumClassSingle?): String = when (value) { fun case_2(value_1: _EnumClassSingle?): String = when (value_1) {
_EnumClassSingle.EVERYTHING -> "" _EnumClassSingle.EVERYTHING -> ""
null -> "" null -> ""
} }
@@ -3,37 +3,37 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 11 PARAGRAPH: 11
SENTENCE: [8] The bound expression is of a nullable type and one of the cases above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null. SENTENCE: [8] The bound expression is of a nullable type and one of the areas above is met for its non-nullable counterpart and, in addition, there is a condition containing literal null.
NUMBER: 3 NUMBER: 3
DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered and contains a null check. DESCRIPTION: Check when exhaustive when possible subtypes of the sealed class are covered and contains a null check.
*/ */
// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes and null value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class subtypes and null value covered).
fun case_1(expr: _SealedClass?): Int = when (expr) { fun case_1(value_1: _SealedClass?): Int = when (value_1) {
is _SealedChild1 -> <!DEBUG_INFO_SMARTCAST!>expr<!>.number is _SealedChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.number
is _SealedChild2 -> <!DEBUG_INFO_SMARTCAST!>expr<!>.e1 + <!DEBUG_INFO_SMARTCAST!>expr<!>.e2 is _SealedChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.e1 + <!DEBUG_INFO_SMARTCAST!>value_1<!>.e2
is _SealedChild3 -> <!DEBUG_INFO_SMARTCAST!>expr<!>.m1 + <!DEBUG_INFO_SMARTCAST!>expr<!>.m2 is _SealedChild3 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1 + <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2
null -> 0 null -> 0
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (sealed class itself and null value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (sealed class itself and null value covered).
fun case_2(expr: _SealedClass?): String = when (expr) { fun case_2(value_1: _SealedClass?): String = when (value_1) {
is _SealedClass -> "" is _SealedClass -> ""
null -> "" null -> ""
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class with methods subtypes and null value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (all sealed class with methods subtypes and null value covered).
fun case_3(expr: _SealedClassWithMethods?): String = when (expr) { fun case_3(value_1: _SealedClassWithMethods?): String = when (value_1) {
is _SealedWithMethodsChild1 -> <!DEBUG_INFO_SMARTCAST!>expr<!>.m1() is _SealedWithMethodsChild1 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m1()
is _SealedWithMethodsChild2 -> <!DEBUG_INFO_SMARTCAST!>expr<!>.m2() is _SealedWithMethodsChild2 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m2()
is _SealedWithMethodsChild3 -> <!DEBUG_INFO_SMARTCAST!>expr<!>.m3() is _SealedWithMethodsChild3 -> <!DEBUG_INFO_SMARTCAST!>value_1<!>.m3()
null -> "" null -> ""
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (all objects covered using implicit equality operator and null value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (all objects covered using implicit equality operator and null value covered).
fun case_4(expr: _SealedClassWithObjects?): String = when (expr) { fun case_4(value_1: _SealedClassWithObjects?): String = when (value_1) {
_SealedWithObjectsChild1 -> "" _SealedWithObjectsChild1 -> ""
_SealedWithObjectsChild2 -> "" _SealedWithObjectsChild2 -> ""
_SealedWithObjectsChild3 -> "" _SealedWithObjectsChild3 -> ""
@@ -41,7 +41,7 @@ fun case_4(expr: _SealedClassWithObjects?): String = when (expr) {
} }
// CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects covered + null value covered). // CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects covered + null value covered).
fun case_5(value: _SealedClassMixed?): String = when (value) { fun case_5(value_1: _SealedClassMixed?): String = when (value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> "" is _SealedMixedChild3 -> ""
@@ -55,7 +55,7 @@ fun case_5(value: _SealedClassMixed?): String = when (value) {
CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects (using type checking operator) covered + null value covered). CASE DESCRIPTION: Checking for exhaustive 'when' (all subtypes and objects (using type checking operator) covered + null value covered).
DISCUSSION: is it correct that objects can be checked using the type checking operator? DISCUSSION: is it correct that objects can be checked using the type checking operator?
*/ */
fun case_6(value: _SealedClassMixed?): String = when (value) { fun case_6(value_1: _SealedClassMixed?): String = when (value_1) {
is _SealedMixedChild1 -> "" is _SealedMixedChild1 -> ""
is _SealedMixedChild2 -> "" is _SealedMixedChild2 -> ""
is _SealedMixedChild3 -> "" is _SealedMixedChild3 -> ""
@@ -1,13 +1,13 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 2 PARAGRAPH: 2
SENTENCE: [3] When expression has two different forms: with bound value and without it. SENTENCE: [3] When expression has two different forms: with bound value and without it.
NUMBER: 1 NUMBER: 1
DESCRIPTION: Empty 'when' with bound value. DESCRIPTION: Empty 'when' with bound value.
*/ */
fun case_1(value: Int) { fun case_1(value_1: Int) {
when (<!UNUSED_EXPRESSION!>value<!>) {} when (<!UNUSED_EXPRESSION!>value_1<!>) {}
} }
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 2 PARAGRAPH: 2
SENTENCE: [3] When expression has two different forms: with bound value and without it. SENTENCE: [3] When expression has two different forms: with bound value and without it.
NUMBER: 2 NUMBER: 2
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 3 PARAGRAPH: 3
SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry. SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry.
NUMBER: 1 NUMBER: 1
@@ -9,10 +9,10 @@
*/ */
// CASE DESCRIPTION: 'When' with break expression (without label). // CASE DESCRIPTION: 'When' with break expression (without label).
fun case_1(value: Int): String { fun case_1(value_1: Int): String {
while (true) { while (true) {
when { when {
value == 1 -> <!BREAK_OR_CONTINUE_IN_WHEN!>break<!> value_1 == 1 -> <!BREAK_OR_CONTINUE_IN_WHEN!>break<!>
} }
} }
@@ -20,10 +20,10 @@ fun case_1(value: Int): String {
} }
// CASE DESCRIPTION: 'When' with continue expression (without label). // CASE DESCRIPTION: 'When' with continue expression (without label).
fun case_2(value: Int): String { fun case_2(value_1: Int): String {
while (true) { while (true) {
when { when {
value == 1 -> <!BREAK_OR_CONTINUE_IN_WHEN!>continue<!> value_1 == 1 -> <!BREAK_OR_CONTINUE_IN_WHEN!>continue<!>
} }
} }
@@ -3,20 +3,20 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 3 PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 1 NUMBER: 1
DESCRIPTION: 'When' without bound value and with not boolean condition in 'when condition'. DESCRIPTION: 'When' without bound value and with not boolean condition in 'when condition'.
*/ */
fun case_1(value1: Int, value2: String, value3: _BasicTypesProvider): String { fun case_1(value_1: Int, value_2: String, value_3: _BasicTypesProvider): String {
when { when {
<!TYPE_MISMATCH!>.012f / value1<!> -> return "" <!TYPE_MISMATCH!>.012f / value_1<!> -> return ""
<!TYPE_MISMATCH!>"$value2..."<!> -> return "" <!TYPE_MISMATCH!>"$value_2..."<!> -> return ""
<!CONSTANT_EXPECTED_TYPE_MISMATCH!>'-'<!> -> return "" <!CONSTANT_EXPECTED_TYPE_MISMATCH!>'-'<!> -> return ""
<!TYPE_MISMATCH!>{}<!> -> return "" <!TYPE_MISMATCH!>{}<!> -> return ""
<!TYPE_MISMATCH!>value3.getAny()<!> -> return "" <!TYPE_MISMATCH!>value_3.getAny()<!> -> return ""
<!TYPE_MISMATCH!>-10..-1<!> -> return "" <!TYPE_MISMATCH!>-10..-1<!> -> return ""
} }
@@ -3,18 +3,18 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 3 PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 2 NUMBER: 2
DESCRIPTION: 'When' without bound value and not allowed comma in when entry. DESCRIPTION: 'When' without bound value and not allowed comma in when entry.
*/ */
fun case_1(value1: _BasicTypesProvider) { fun case_1(value_1: _BasicTypesProvider) {
when { when {
getBoolean()<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> value1.getBoolean() -> return getBoolean()<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> value_1.getBoolean() -> return
value1.getBoolean() && getBoolean()<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> getLong() == 1000L -> return value_1.getBoolean() && getBoolean()<!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> getLong() == 1000L -> return
<!TYPE_MISMATCH!>value1.getList()<!><!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> <!TYPE_MISMATCH!>getLong()<!><!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> <!TYPE_MISMATCH!>{}<!><!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> <!TYPE_MISMATCH!>Any()<!><!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> throw Exception() -> return <!TYPE_MISMATCH!>value_1.getList()<!><!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> <!TYPE_MISMATCH!>getLong()<!><!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> <!TYPE_MISMATCH!>{}<!><!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> <!TYPE_MISMATCH!>Any()<!><!COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT!>,<!> throw Exception() -> return
} }
<!UNREACHABLE_CODE!>return<!> <!UNREACHABLE_CODE!>return<!>
@@ -6,7 +6,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 3 PARAGRAPH: 3
SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry. SENTENCE: [1] When expression without bound value (the form where the expression enclosed in parantheses is absent) evaluates one of the many different expressions based on corresponding conditions present in the same when entry.
NUMBER: 1 NUMBER: 1
@@ -14,80 +14,80 @@
*/ */
// CASE DESCRIPTION: 'When' with control structure body as literals. // CASE DESCRIPTION: 'When' with control structure body as literals.
fun case_1(value: Int) { fun case_1(value_1: Int) {
when { when {
value == 1 -> true value_1 == 1 -> true
value == 2 -> 100 value_1 == 2 -> 100
value == 3 -> -.09f value_1 == 3 -> -.09f
value == 4 -> '.' value_1 == 4 -> '.'
value == 5 -> "..." value_1 == 5 -> "..."
value == 6 -> null value_1 == 6 -> null
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as arithmetic expressions. // CASE DESCRIPTION: 'When' with control structure body as arithmetic expressions.
fun case_2(value: Int, value1: Byte, value2: _BasicTypesProvider) { fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) {
when { when {
value == 1 -> -.09 % 10L value_1 == 1 -> -.09 % 10L
value == 3 -> value1 / -5 value_1 == 3 -> value_2 / -5
value == 2 -> value2.getChar(99) - 11 + 90 value_1 == 2 -> value_3.getChar(99) - 11 + 90
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as boolean expressions (logical, equality and comparison). // CASE DESCRIPTION: 'When' with control structure body as boolean expressions (logical, equality and comparison).
fun case_3(value: Int, value1: Boolean, value2: Long) { fun case_3(value_1: Int, value_2: Boolean, value_3: Long) {
when { when {
value == 1 -> value1 value_1 == 1 -> value_2
value == 2 -> !value1 value_1 == 2 -> !value_2
value == 3 -> getBoolean() && value1 value_1 == 3 -> getBoolean() && value_2
value == 5 -> getChar(10) != 'a' value_1 == 5 -> getChar(10) != 'a'
value == 6 -> getList() === getAny() value_1 == 6 -> getList() === getAny()
value == 7 -> value2 <= 11 value_1 == 7 -> value_3 <= 11
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as concatenations. // CASE DESCRIPTION: 'When' with control structure body as concatenations.
fun case_4(value: Int, value1: String, value2: String) { fun case_4(value_1: Int, value_2: String, value_3: String) {
when { when {
value == 1 -> "..." + value1 + "" + "$value2" + "..." value_1 == 1 -> "..." + value_2 + "" + "$value_3" + "..."
value == 2 -> value1 + getString() value_1 == 2 -> value_2 + getString()
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as when expression. // CASE DESCRIPTION: 'When' with control structure body as when expression.
fun case_5(value: Int, value1: Int, value2: Boolean?) { fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
when { when {
value == 1 -> when { value_1 == 1 -> when {
value1 > 1000 -> "1" value_2 > 1000 -> "1"
value1 > 100 -> "2" value_2 > 100 -> "2"
else -> "3" else -> "3"
} }
value == 2 -> when { value_1 == 2 -> when {
value1 > 1000 -> "1" value_2 > 1000 -> "1"
value1 > 100 -> "2" value_2 > 100 -> "2"
} }
value == 3 -> when {} value_1 == 3 -> when {}
value == 4 -> when (value2) { value_1 == 4 -> when (value_3) {
true -> "1" true -> "1"
false -> "2" false -> "2"
null -> "3" null -> "3"
} }
value == 5 -> when (value2) { value_1 == 5 -> when (value_3) {
true -> "1" true -> "1"
false -> "2" false -> "2"
} }
value == 6 -> when (value2) {} value_1 == 6 -> when (value_3) {}
} }
} }
// CASE DESCRIPTION: 'When' as expression with control structure body as when expression (must be exhaustive). // CASE DESCRIPTION: 'When' as expression with control structure body as when expression (must be exhaustive).
fun case_6(value: Int, value1: Int, value2: Boolean?) = when { fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when {
value == 1 -> when { value_1 == 1 -> when {
value1 > 1000 -> 1 value_2 > 1000 -> 1
value1 > 100 -> 2 value_2 > 100 -> 2
else -> 3 else -> 3
} }
else -> when (value2) { else -> when (value_3) {
true -> 1 true -> 1
false -> 2 false -> 2
null -> 3 null -> 3
@@ -95,138 +95,138 @@ fun case_6(value: Int, value1: Int, value2: Boolean?) = when {
} }
// CASE DESCRIPTION: 'When' with control structure body as if expression. // CASE DESCRIPTION: 'When' with control structure body as if expression.
fun case_7(value: Int, value1: Int, value2: Boolean?) { fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) {
when { when {
value == 1 -> if (value1 > 1000) "1" value_1 == 1 -> if (value_2 > 1000) "1"
value == 2 -> if (value1 > 1000) "1" value_1 == 2 -> if (value_2 > 1000) "1"
else "2" else "2"
value == 3 -> if (value1 < 100) "1" value_1 == 3 -> if (value_2 < 100) "1"
else if (value1 < 10) "2" else if (value_2 < 10) "2"
else "4" else "4"
value == 4 -> if (value2 == null) "1" value_1 == 4 -> if (value_3 == null) "1"
else if (value2) "2" else if (value_3) "2"
else if (!value2) "3" else if (!value_3) "3"
} }
} }
// CASE DESCRIPTION: 'When' as expression with control structure body as if expression (must be exhaustive). // CASE DESCRIPTION: 'When' as expression with control structure body as if expression (must be exhaustive).
fun case_8(value: Int, value1: Int) = when { fun case_8(value_1: Int, value_2: Int) = when {
value == 1 -> if (value1 > 1000) "1" value_1 == 1 -> if (value_2 > 1000) "1"
else "2" else "2"
else -> if (value1 < 100) "1" else -> if (value_2 < 100) "1"
else if (value1 < 10) "2" else if (value_2 < 10) "2"
else "4" else "4"
} }
// CASE DESCRIPTION: 'When' with control structure body as try expression. // CASE DESCRIPTION: 'When' with control structure body as try expression.
fun case_9(value: Int, value1: String, value2: String) = when { fun case_9(value_1: Int, value_2: String, value_3: String) = when {
value == 1 -> <!IMPLICIT_CAST_TO_ANY!>try { 4 } catch (e: Exception) { 5 }<!> value_1 == 1 -> <!IMPLICIT_CAST_TO_ANY!>try { 4 } catch (e: Exception) { 5 }<!>
value == 2 -> <!IMPLICIT_CAST_TO_ANY!>try { throw Exception() } catch (e: Exception) { value1 }<!> value_1 == 2 -> <!IMPLICIT_CAST_TO_ANY!>try { throw Exception() } catch (e: Exception) { value_2 }<!>
else -> <!IMPLICIT_CAST_TO_ANY!>try { throw Exception() } catch (e: Exception) { {value2} } finally { }<!> else -> <!IMPLICIT_CAST_TO_ANY!>try { throw Exception() } catch (e: Exception) { {value_3} } finally { }<!>
} }
// CASE DESCRIPTION: 'When' with control structure body as elvis operator expression. // CASE DESCRIPTION: 'When' with control structure body as elvis operator expression.
fun case_10(value: Int, value1: String?, value2: String?) { fun case_10(value_1: Int, value_2: String?, value_3: String?) {
when { when {
value == 1 -> value1 ?: true value_1 == 1 -> value_2 ?: true
value == 2 -> value1 ?: value2 ?: true value_1 == 2 -> value_2 ?: value_3 ?: true
value == 3 -> value1!! <!USELESS_ELVIS!>?: true<!> value_1 == 3 -> value_2!! <!USELESS_ELVIS!>?: true<!>
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as range expression. // CASE DESCRIPTION: 'When' with control structure body as range expression.
fun case_11(value: Int) { fun case_11(value_1: Int) {
when { when {
value == 1 -> 1..10 value_1 == 1 -> 1..10
value == 2 -> -100L..100L value_1 == 2 -> -100L..100L
value == 3 -> -getInt()..getLong() value_1 == 3 -> -getInt()..getLong()
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as cast expression. // CASE DESCRIPTION: 'When' with control structure body as cast expression.
fun case_12(value: Int, value1: Collection<Int>, value2: Collection<Int>?) { fun case_12(value_1: Int, value_2: Collection<Int>, value_3: Collection<Int>?) {
when { when {
value == 1 -> value1 as MutableList<Int> value_1 == 1 -> value_2 as MutableList<Int>
value == 2 -> value1 as? MutableList<Int> value_1 == 2 -> value_2 as? MutableList<Int>
value == 3 -> value2 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!> value_1 == 3 -> value_3 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!>
value == 4 -> (value1 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int> value_1 == 4 -> (value_2 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int>
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as prefix operator expression. // CASE DESCRIPTION: 'When' with control structure body as prefix operator expression.
fun case_13(value: Int, value1: Int, value2: Int, value3: Boolean) { fun case_13(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean) {
var mutableValue1 = value1 var mutablevalue_2 = value_2
var mutableValue2 = value2 var mutablevalue_3 = value_3
when { when {
value == 1 -> ++mutableValue1 value_1 == 1 -> ++mutablevalue_2
value == 2 -> --mutableValue2 value_1 == 2 -> --mutablevalue_3
value == 3 -> !value3 value_1 == 3 -> !value_4
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as postfix operator expression. // CASE DESCRIPTION: 'When' with control structure body as postfix operator expression.
fun case_14(value: Int, value1: Int, value2: Int, value3: Boolean?) { fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) {
var mutableValue1 = value1 var mutablevalue_2 = value_2
var mutableValue2 = value2 var mutablevalue_3 = value_3
when { when {
value == 1 -> <!UNUSED_CHANGED_VALUE!>mutableValue1++<!> value_1 == 1 -> <!UNUSED_CHANGED_VALUE!>mutablevalue_2++<!>
value == 2 -> <!UNUSED_CHANGED_VALUE!>mutableValue2--<!> value_1 == 2 -> <!UNUSED_CHANGED_VALUE!>mutablevalue_3--<!>
value == 3 -> value3!! value_1 == 3 -> value_4!!
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as indexing expression. // CASE DESCRIPTION: 'When' with control structure body as indexing expression.
fun case_15(value: Int, value1: List<Int>, value2: List<List<List<List<Int>>>>) { fun case_15(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>>>) {
when { when {
value == 1 -> value1[0] value_1 == 1 -> value_2[0]
value == 2 -> value2[0][-4][1][-1] value_1 == 2 -> value_3[0][-4][1][-1]
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as call expression. // CASE DESCRIPTION: 'When' with control structure body as call expression.
fun case_16(value: Int, value1: _Class, value2: _Class?, value3: Int) { fun case_16(value_1: Int, value_2: _Class, value_3: _Class?, value_4: Int) {
fun __fun_1(): () -> Unit { return fun() { } } fun __fun_1(): () -> Unit { return fun() { } }
when { when {
value == 1 -> _funWithoutArgs() value_1 == 1 -> _funWithoutArgs()
value == 2 -> __fun_1()() value_1 == 2 -> __fun_1()()
value == 3 -> value1.fun_2(value3) value_1 == 3 -> value_2.fun_2(value_4)
value == 4 -> value2?.fun_2(value3) value_1 == 4 -> value_3?.fun_2(value_4)
value == 5 -> value2!!.fun_2(value3) value_1 == 5 -> value_3!!.fun_2(value_4)
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as property access expression. // CASE DESCRIPTION: 'When' with control structure body as property access expression.
fun case_17(value: Int, value1: _Class, value2: _Class?) { fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) {
when { when {
value == 1 -> value1.prop_1 value_1 == 1 -> value_2.prop_1
value == 2 -> value2?.prop_1 value_1 == 2 -> value_3?.prop_1
value == 3 -> value1::prop_1.get() value_1 == 3 -> value_2::prop_1.get()
value == 4 -> value2!!::prop_3.get() value_1 == 4 -> value_3!!::prop_3.get()
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as fun literal. // CASE DESCRIPTION: 'When' with control structure body as fun literal.
fun case_18(value: Int) { fun case_18(value_1: Int) {
val fun_1 = fun(): Int { return 0 } val fun_1 = fun(): Int { return 0 }
when { when {
value == 1 -> fun() {} value_1 == 1 -> fun() {}
value == 2 -> fun(): Int { return 0 } value_1 == 2 -> fun(): Int { return 0 }
value == 3 -> fun(): () -> Unit { return fun() {} } value_1 == 3 -> fun(): () -> Unit { return fun() {} }
value == 4 -> fun_1 value_1 == 4 -> fun_1
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as lambda literal. // CASE DESCRIPTION: 'When' with control structure body as lambda literal.
fun case_19(value: Int): () -> Any { fun case_19(value_1: Int): () -> Any {
val lambda_1 = { 0 } val lambda_1 = { 0 }
return when { return when {
value == 1 -> lambda_1 value_1 == 1 -> lambda_1
value == 2 -> { { {} } } value_1 == 2 -> { { {} } }
else -> { -> (Int) else -> { -> (Int)
{ arg: Int -> { { println(arg) } } } { arg: Int -> { { println(arg) } } }
} }
@@ -234,18 +234,18 @@ fun case_19(value: Int): () -> Any {
} }
// CASE DESCRIPTION: 'When' with control structure body as object literal. // CASE DESCRIPTION: 'When' with control structure body as object literal.
fun case_20(value: Int) { fun case_20(value_1: Int) {
val object_1 = object { val object_1 = object {
val prop_1 = 1 val prop_1 = 1
} }
when { when {
value == 1 -> object {} value_1 == 1 -> object {}
value == 2 -> object { value_1 == 2 -> object {
private fun fun_1() { } private fun fun_1() { }
val prop_1 = 1 val prop_1 = 1
} }
value == 3 -> object_1 value_1 == 3 -> object_1
} }
} }
@@ -255,41 +255,41 @@ class A {
val lambda_1 = { 1 } val lambda_1 = { 1 }
fun fun_1(): Int { return 1 } fun fun_1(): Int { return 1 }
fun case_21(value: Int) { fun case_21(value_1: Int) {
when { when {
value == 1 -> this value_1 == 1 -> this
value == 2 -> ((this)) value_1 == 2 -> ((this))
value == 3 -> this::prop_1.get() value_1 == 3 -> this::prop_1.get()
value == 4 -> this.prop_1 value_1 == 4 -> this.prop_1
value == 5 -> this.lambda_1() value_1 == 5 -> this.lambda_1()
value == 6 -> this::lambda_1.get()() value_1 == 6 -> this::lambda_1.get()()
value == 7 -> this.fun_1() value_1 == 7 -> this.fun_1()
value == 8 -> this::fun_1.invoke() value_1 == 8 -> this::fun_1.invoke()
} }
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as throw expression. // CASE DESCRIPTION: 'When' with control structure body as throw expression.
fun case_22(value: Int) { fun case_22(value_1: Int) {
when { when {
value == 1 -> throw Exception() value_1 == 1 -> throw Exception()
value == 2 -> throw throw throw Exception() value_1 == 2 -> throw throw throw Exception()
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as return expression. // CASE DESCRIPTION: 'When' with control structure body as return expression.
fun case_23(value: Int) { fun case_23(value_1: Int) {
fun r_1() { fun r_1() {
when { when {
value == 1 -> return value_1 == 1 -> return
value == 2 -> <!UNREACHABLE_CODE!>return return<!> return value_1 == 2 -> <!UNREACHABLE_CODE!>return return<!> return
} }
} }
fun r_2(): List<Int>? { fun r_2(): List<Int>? {
when { when {
value == 1 -> return listOf(0, 1, 2) value_1 == 1 -> return listOf(0, 1, 2)
value == 2 -> return null value_1 == 2 -> return null
} }
return null return null
@@ -297,24 +297,24 @@ fun case_23(value: Int) {
} }
// CASE DESCRIPTION: 'When' with control structure body as continue expression. // CASE DESCRIPTION: 'When' with control structure body as continue expression.
fun case_24(value: Int) { fun case_24(value_1: Int) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
when { when {
value == 1 -> continue@loop1 value_1 == 1 -> continue@loop1
value == 2 -> continue@loop2 value_1 == 2 -> continue@loop2
} }
} }
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as break expression. // CASE DESCRIPTION: 'When' with control structure body as break expression.
fun case_25(value: Int) { fun case_25(value_1: Int) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
when { when {
value == 1 -> break@loop1 value_1 == 1 -> break@loop1
value == 2 -> break@loop2 value_1 == 2 -> break@loop2
} }
} }
} }
@@ -5,7 +5,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 3 PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 1 NUMBER: 1
@@ -13,14 +13,14 @@
*/ */
// CASE DESCRIPTION: 'When' with boolean expressions and else branch. // CASE DESCRIPTION: 'When' with boolean expressions and else branch.
fun case_1(value1: Boolean, value2: Long): Int { fun case_1(value_1: Boolean, value_2: Long): Int {
return when { return when {
value1 -> 1 value_1 -> 1
getBoolean() && value1 -> 2 getBoolean() && value_1 -> 2
getChar(10) != 'a' -> 3 getChar(10) != 'a' -> 3
getList() === getAny() -> 4 getList() === getAny() -> 4
value2 <= 11 -> 5 value_2 <= 11 -> 5
!value1 -> 6 !value_1 -> 6
else -> 7 else -> 7
} }
} }
@@ -29,12 +29,12 @@ fun case_1(value1: Boolean, value2: Long): Int {
CASE DESCRIPTION: 'When' with boolean expressions. CASE DESCRIPTION: 'When' with boolean expressions.
NOTE: for potential analysys on exhaustive by enum of when without bound value. NOTE: for potential analysys on exhaustive by enum of when without bound value.
*/ */
fun case_2(value: _EnumClass) { fun case_2(value_1: _EnumClass) {
when { when {
value == _EnumClass.NORTH -> {} value_1 == _EnumClass.NORTH -> {}
value == _EnumClass.SOUTH -> {} value_1 == _EnumClass.SOUTH -> {}
value == _EnumClass.WEST -> {} value_1 == _EnumClass.WEST -> {}
value == _EnumClass.EAST -> {} value_1 == _EnumClass.EAST -> {}
} }
} }
@@ -42,10 +42,10 @@ fun case_2(value: _EnumClass) {
CASE DESCRIPTION: 'When' with boolean expressions. CASE DESCRIPTION: 'When' with boolean expressions.
NOTE: for potential analysys on exhaustive by boolean of when without bound value. NOTE: for potential analysys on exhaustive by boolean of when without bound value.
*/ */
fun case_3(value: Boolean) { fun case_3(value_1: Boolean) {
when { when {
value == true -> return value_1 == true -> return
value == false -> return value_1 == false -> return
} }
} }
@@ -53,11 +53,11 @@ fun case_3(value: Boolean) {
CASE DESCRIPTION: 'When' with boolean literals. CASE DESCRIPTION: 'When' with boolean literals.
NOTE: for potential mark code after true branch as unreacable. NOTE: for potential mark code after true branch as unreacable.
*/ */
fun case_4(value1: Boolean) { fun case_4(value_1: Boolean) {
when { when {
false -> return false -> return
true -> return true -> return
value1 -> return value_1 -> return
} }
} }
@@ -65,60 +65,60 @@ fun case_4(value1: Boolean) {
CASE DESCRIPTION: 'When' with boolean constants. CASE DESCRIPTION: 'When' with boolean constants.
NOTE: for potential const propagation use in this case. NOTE: for potential const propagation use in this case.
*/ */
fun case_5(value1: Boolean) { fun case_5(value_1: Boolean) {
val value2 = false val value_2 = false
val value3 = false || !!!false || false val value_3 = false || !!!false || false
when { when {
value3 -> return value_3 -> return
value2 -> return value_2 -> return
value1 -> return value_1 -> return
} }
} }
// CASE DESCRIPTION: 'When' with type checking operator. // CASE DESCRIPTION: 'When' with type checking operator.
fun case_6(value: Any) { fun case_6(value_1: Any) {
when { when {
value is Nothing -> {} value_1 is Nothing -> {}
value is Int -> {} value_1 is Int -> {}
value is Boolean -> {} value_1 is Boolean -> {}
value is String -> {} value_1 is String -> {}
value is Number -> {} value_1 is Number -> {}
value is Float -> {} value_1 is Float -> {}
<!USELESS_IS_CHECK!>value is Any<!> -> {} <!USELESS_IS_CHECK!>value_1 is Any<!> -> {}
} }
} }
/* /*
CASE DESCRIPTION: 'When' with invert type checking operator. CASE DESCRIPTION: 'When' with invert type checking operator.
NOTE: for potential analysys on exhaustive of when without bound value. NOTE: for potential analysys on exhaustive of when without bound value_1.
*/ */
fun case_7(value: Any) { fun case_7(value_1: Any) {
when { when {
value !is Number -> {} value_1 !is Number -> {}
value is Float -> {} value_1 is Float -> {}
<!USELESS_IS_CHECK!>value is Number<!> -> {} <!USELESS_IS_CHECK!>value_1 is Number<!> -> {}
<!USELESS_IS_CHECK!>value is Any<!> -> {} <!USELESS_IS_CHECK!>value_1 is Any<!> -> {}
} }
} }
/* /*
CASE DESCRIPTION: 'When' with type checking operator by sealed class. CASE DESCRIPTION: 'When' with type checking operator by sealed class.
NOTE: for potential analysys on exhaustive by sealed class of when without bound value. NOTE: for potential analysys on exhaustive by sealed class of when without bound value_1.
*/ */
fun case_8(value: _SealedClass) { fun case_8(value_1: _SealedClass) {
when { when {
value is _SealedChild1 -> {} value_1 is _SealedChild1 -> {}
value is _SealedChild2 -> {} value_1 is _SealedChild2 -> {}
value is _SealedChild3 -> {} value_1 is _SealedChild3 -> {}
} }
} }
// CASE DESCRIPTION: 'When' with containment operator. // CASE DESCRIPTION: 'When' with containment operator.
fun case_9(value: Int, value1: IntRange) { fun case_9(value_1: Int, value_2: IntRange) {
when { when {
value in -10..100L -> {} value_1 in -10..100L -> {}
value in value1 -> {} value_1 in value_2 -> {}
value !in listOf(0, 1, 2) -> {} value_1 !in listOf(0, 1, 2) -> {}
} }
} }
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 3 PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 2 NUMBER: 2
@@ -3,17 +3,17 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 3 PARAGRAPH: 3
SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance. SENTENCE: [2] Each entry consists of a boolean condition (or a special else condition), each of which is checked and evaluated in order of appearance.
NUMBER: 3 NUMBER: 3
DESCRIPTION: 'When' without bound value and with Nothing in condition (subtype of Boolean). DESCRIPTION: 'When' without bound value and with Nothing in condition (subtype of Boolean).
UNEXPECTED BEHAVIOUR DISCUSSION
ISSUES: KT-25948 ISSUES: KT-25948
*/ */
// CASE DESCRIPTION: 'When' with return expression in condition. // CASE DESCRIPTION: 'When' with return expression in condition.
fun case_1(<!UNUSED_PARAMETER!>value1<!>: _BasicTypesProvider) { fun case_1(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) {
when { when {
return -> <!UNREACHABLE_CODE!>return<!> return -> <!UNREACHABLE_CODE!>return<!>
<!UNREACHABLE_CODE!>return == return -> return<!> <!UNREACHABLE_CODE!>return == return -> return<!>
@@ -24,7 +24,7 @@ fun case_1(<!UNUSED_PARAMETER!>value1<!>: _BasicTypesProvider) {
} }
// CASE DESCRIPTION: 'When' with throw expression in condition. // CASE DESCRIPTION: 'When' with throw expression in condition.
fun case_2(<!UNUSED_PARAMETER!>value1<!>: _BasicTypesProvider) { fun case_2(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) {
when { when {
throw Exception() -> <!UNREACHABLE_CODE!>return<!> throw Exception() -> <!UNREACHABLE_CODE!>return<!>
<!UNREACHABLE_CODE!>(throw Exception()) == (throw Exception()) -> return<!> <!UNREACHABLE_CODE!>(throw Exception()) == (throw Exception()) -> return<!>
@@ -35,7 +35,7 @@ fun case_2(<!UNUSED_PARAMETER!>value1<!>: _BasicTypesProvider) {
} }
// CASE DESCRIPTION: 'When' with break expression in condition. // CASE DESCRIPTION: 'When' with break expression in condition.
fun case_3(<!UNUSED_PARAMETER!>value1<!>: _BasicTypesProvider) { fun case_3(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
loop3@ while (true) { loop3@ while (true) {
@@ -50,7 +50,7 @@ fun case_3(<!UNUSED_PARAMETER!>value1<!>: _BasicTypesProvider) {
} }
// CASE DESCRIPTION: 'When' with continue expression in condition. // CASE DESCRIPTION: 'When' with continue expression in condition.
fun case_4(<!UNUSED_PARAMETER!>value1<!>: _BasicTypesProvider): String { fun case_4(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider): String {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
loop3@ while (true) { loop3@ while (true) {
@@ -65,19 +65,19 @@ fun case_4(<!UNUSED_PARAMETER!>value1<!>: _BasicTypesProvider): String {
} }
// CASE DESCRIPTION: 'When' with values of Nothing type. // CASE DESCRIPTION: 'When' with values of Nothing type.
fun case_6(value1: Nothing, <!UNUSED_PARAMETER!>value2<!>: _BasicTypesProvider): String { fun case_6(value_1: Nothing, <!UNUSED_PARAMETER!>value_2<!>: _BasicTypesProvider): String {
when { when {
value1 -> <!UNREACHABLE_CODE!>return ""<!> value_1 -> <!UNREACHABLE_CODE!>return ""<!>
<!UNREACHABLE_CODE!>value2.getNothing() -> return ""<!> <!UNREACHABLE_CODE!>value_2.getNothing() -> return ""<!>
<!UNREACHABLE_CODE!>getNothing() -> return ""<!> <!UNREACHABLE_CODE!>getNothing() -> return ""<!>
<!UNREACHABLE_CODE!>value1 && (getNothing() == value2.getNothing()) -> return ""<!> <!UNREACHABLE_CODE!>value_1 && (getNothing() == value_2.getNothing()) -> return ""<!>
} }
<!UNREACHABLE_CODE!>return ""<!> <!UNREACHABLE_CODE!>return ""<!>
} }
// CASE DESCRIPTION: 'When' with mixed Nothing expression in condition. // CASE DESCRIPTION: 'When' with mixed Nothing expression in condition.
fun case_5(<!UNUSED_PARAMETER!>value1<!>: _BasicTypesProvider, <!UNUSED_PARAMETER!>value2<!>: Nothing) { fun case_5(<!UNUSED_PARAMETER!>value_1<!>: _BasicTypesProvider, <!UNUSED_PARAMETER!>value_2<!>: Nothing) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
loop3@ while (true) { loop3@ while (true) {
@@ -87,9 +87,9 @@ fun case_5(<!UNUSED_PARAMETER!>value1<!>: _BasicTypesProvider, <!UNUSED_PARAMETE
<!UNREACHABLE_CODE!>continue@loop1 != 10L && (return return) == continue@loop1 -> return<!> <!UNREACHABLE_CODE!>continue@loop1 != 10L && (return return) == continue@loop1 -> return<!>
<!UNREACHABLE_CODE!>return continue@loop1 -> return<!> <!UNREACHABLE_CODE!>return continue@loop1 -> return<!>
<!UNREACHABLE_CODE!>(throw break@loop1) && break@loop3 -> return<!> <!UNREACHABLE_CODE!>(throw break@loop1) && break@loop3 -> return<!>
<!UNREACHABLE_CODE!>(throw getNothing()) && value1.getNothing() -> return<!> <!UNREACHABLE_CODE!>(throw getNothing()) && value_1.getNothing() -> return<!>
<!UNREACHABLE_CODE!>return return return value2 -> return<!> <!UNREACHABLE_CODE!>return return return value_2 -> return<!>
<!UNREACHABLE_CODE!>getNothing() != 10L && (return return) == value2 -> return<!> <!UNREACHABLE_CODE!>getNothing() != 10L && (return return) == value_2 -> return<!>
} }
} }
} }
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 5 PARAGRAPH: 5
SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated. SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated.
NUMBER: 1 NUMBER: 1
@@ -9,16 +9,16 @@
*/ */
// CASE DESCRIPTION: 'When' with 'else' branch in the first position. // CASE DESCRIPTION: 'When' with 'else' branch in the first position.
fun case_1(<!UNUSED_PARAMETER!>value<!>: Int): String = when { fun case_1(<!UNUSED_PARAMETER!>value_1<!>: Int): String = when {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>value == 1 -> ""<!> <!UNREACHABLE_CODE!>value_1 == 1 -> ""<!>
} }
// CASE DESCRIPTION: 'When' with 'else' branch in the middle position. // CASE DESCRIPTION: 'When' with 'else' branch in the middle position.
fun case_2(value: Int): String = when { fun case_2(value_1: Int): String = when {
value == 1 -> "" value_1 == 1 -> ""
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>value == 2 -> ""<!> <!UNREACHABLE_CODE!>value_1 == 2 -> ""<!>
} }
// CASE DESCRIPTION: 'When' with two 'else' branches. // CASE DESCRIPTION: 'When' with two 'else' branches.
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 5 PARAGRAPH: 5
SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated. SENTENCE: [1] The else entry is also special in the sense that it must be the last entry in the expression, otherwise a compiler error must be generated.
NUMBER: 1 NUMBER: 1
@@ -9,17 +9,17 @@
*/ */
// CASE DESCRIPTION: 'When' with else branch as statement // CASE DESCRIPTION: 'When' with else branch as statement
fun case_1(value: Int): String { fun case_1(value_1: Int): String {
when { when {
value == 1 -> return "" value_1 == 1 -> return ""
value == 2 -> return "" value_1 == 2 -> return ""
else -> return "" else -> return ""
} }
} }
// CASE DESCRIPTION: 'When' with else branch as expression // CASE DESCRIPTION: 'When' with else branch as expression
fun case_2(value: Int): String = when { fun case_2(value_1: Int): String = when {
value == 1 -> "" value_1 == 1 -> ""
value == 2 -> "" value_1 == 2 -> ""
else -> "" else -> ""
} }
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 6 PARAGRAPH: 6
SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions. SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions.
NUMBER: 1 NUMBER: 1
@@ -9,9 +9,9 @@
*/ */
// CASE DESCRIPTION: 'When' with break expression (without label). // CASE DESCRIPTION: 'When' with break expression (without label).
fun case_1(value: Int): Int { fun case_1(value_1: Int): Int {
while (true) { while (true) {
when (value) { when (value_1) {
1 -> return 1 1 -> return 1
2 -> <!BREAK_OR_CONTINUE_IN_WHEN!>break<!> 2 -> <!BREAK_OR_CONTINUE_IN_WHEN!>break<!>
} }
@@ -21,9 +21,9 @@ fun case_1(value: Int): Int {
} }
// CASE DESCRIPTION: 'When' with continue expression (without label). // CASE DESCRIPTION: 'When' with continue expression (without label).
fun case_2(value: Int): Int { fun case_2(value_1: Int): Int {
while (true) { while (true) {
when (value) { when (value_1) {
1 -> <!BREAK_OR_CONTINUE_IN_WHEN!>continue<!> 1 -> <!BREAK_OR_CONTINUE_IN_WHEN!>continue<!>
2 -> return 1 2 -> return 1
} }
@@ -6,7 +6,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 6 PARAGRAPH: 6
SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions. SENTENCE: [1] When expression with bound value (the form where the expression enclosed in parantheses is present) are very similar to the form without bound value, but use different syntax for conditions.
NUMBER: 1 NUMBER: 1
@@ -14,8 +14,8 @@
*/ */
// CASE DESCRIPTION: 'When' with control structure body as literals. // CASE DESCRIPTION: 'When' with control structure body as literals.
fun case_1(value: Int) { fun case_1(value_1: Int) {
when (value) { when (value_1) {
1 -> true 1 -> true
2 -> 100 2 -> 100
3 -> -.09f 3 -> -.09f
@@ -26,69 +26,69 @@ fun case_1(value: Int) {
} }
// CASE DESCRIPTION: 'When' with control structure body as arithmetic expressions. // CASE DESCRIPTION: 'When' with control structure body as arithmetic expressions.
fun case_2(value: Int, value1: Byte, value2: _BasicTypesProvider) { fun case_2(value_1: Int, value_2: Byte, value_3: _BasicTypesProvider) {
when (value) { when (value_1) {
1 -> -.09 % 10L 1 -> -.09 % 10L
3 -> value1 / -5 3 -> value_2 / -5
2 -> value2.getChar(99) - 11 + 90 2 -> value_3.getChar(99) - 11 + 90
4 -> 100 4 -> 100
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as boolean expressions (logical, equality and comparison). // CASE DESCRIPTION: 'When' with control structure body as boolean expressions (logical, equality and comparison).
fun case_3(value: Int, value1: Boolean, value2: Long) { fun case_3(value_1: Int, value_2: Boolean, value_3: Long) {
when (value) { when (value_1) {
1 -> value1 1 -> value_2
2 -> !value1 2 -> !value_2
3 -> getBoolean() && value1 3 -> getBoolean() && value_2
5 -> getChar(10) != 'a' 5 -> getChar(10) != 'a'
6 -> getList() === getAny() 6 -> getList() === getAny()
7 -> value2 <= 11 7 -> value_3 <= 11
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as concatenations. // CASE DESCRIPTION: 'When' with control structure body as concatenations.
fun case_4(value: Int, value1: String, value2: String) { fun case_4(value_1: Int, value_2: String, value_3: String) {
when (value) { when (value_1) {
1 -> "..." + value1 + "" + "$value2" + "..." 1 -> "..." + value_2 + "" + "$value_3" + "..."
2 -> value1 + getString() 2 -> value_2 + getString()
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as when expression. // CASE DESCRIPTION: 'When' with control structure body as when expression.
fun case_5(value: Int, value1: Int, value2: Boolean?) { fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
when (value) { when (value_1) {
1 -> when (value2) { 1 -> when (value_3) {
value1 > 1000 -> "1" value_2 > 1000 -> "1"
value1 > 100 -> "2" value_2 > 100 -> "2"
else -> "3" else -> "3"
} }
2 -> when (value2) { 2 -> when (value_3) {
value1 > 1000 -> "1" value_2 > 1000 -> "1"
value1 > 100 -> "2" value_2 > 100 -> "2"
} }
3 -> when (value2) {} 3 -> when (value_3) {}
4 -> when (value2) { 4 -> when (value_3) {
true -> "1" true -> "1"
false -> "2" false -> "2"
null -> "3" null -> "3"
} }
5 -> when (value2) { 5 -> when (value_3) {
true -> "1" true -> "1"
false -> "2" false -> "2"
} }
6 -> when (value2) {} 6 -> when (value_3) {}
} }
} }
// CASE DESCRIPTION: 'When' as expression with control structure body as when expression (must be exhaustive). // CASE DESCRIPTION: 'When' as expression with control structure body as when expression (must be exhaustive).
fun case_6(value: Int, value1: Int, value2: Boolean?) = when (value) { fun case_6(value_1: Int, value_2: Int, value_3: Boolean?) = when (value_1) {
1 -> when (value2) { 1 -> when (value_3) {
value1 > 1000 -> 1 value_2 > 1000 -> 1
value1 > 100 -> 2 value_2 > 100 -> 2
else -> 3 else -> 3
} }
else -> when (value2) { else -> when (value_3) {
true -> 1 true -> 1
false -> 2 false -> 2
null -> 3 null -> 3
@@ -96,50 +96,50 @@ fun case_6(value: Int, value1: Int, value2: Boolean?) = when (value) {
} }
// CASE DESCRIPTION: 'When' with control structure body as if expression. // CASE DESCRIPTION: 'When' with control structure body as if expression.
fun case_7(value: Int, value1: Int, value2: Boolean?) { fun case_7(value_1: Int, value_2: Int, value_3: Boolean?) {
when (value) { when (value_1) {
1 -> if (value1 > 1000) "1" 1 -> if (value_2 > 1000) "1"
2 -> if (value1 > 1000) "1" 2 -> if (value_2 > 1000) "1"
else "2" else "2"
3 -> if (value1 < 100) "1" 3 -> if (value_2 < 100) "1"
else if (value1 < 10) "2" else if (value_2 < 10) "2"
else "4" else "4"
4 -> if (value2 == null) "1" 4 -> if (value_3 == null) "1"
else if (<!DEBUG_INFO_SMARTCAST!>value2<!>) "2" else if (<!DEBUG_INFO_SMARTCAST!>value_3<!>) "2"
else if (!<!DEBUG_INFO_SMARTCAST!>value2<!>) "3" else if (!<!DEBUG_INFO_SMARTCAST!>value_3<!>) "3"
} }
} }
// CASE DESCRIPTION: 'When' as expression with control structure body as if expression (must be exhaustive). // CASE DESCRIPTION: 'When' as expression with control structure body as if expression (must be exhaustive).
fun case_8(value: Int, value1: Int) = when (value) { fun case_8(value_1: Int, value_2: Int) = when (value_1) {
1 -> if (value1 > 1000) "1" 1 -> if (value_2 > 1000) "1"
else "2" else "2"
else -> if (value1 < 100) "1" else -> if (value_2 < 100) "1"
else if (value1 < 10) "2" else if (value_2 < 10) "2"
else "4" else "4"
} }
// CASE DESCRIPTION: 'When' with control structure body as try expression. // CASE DESCRIPTION: 'When' with control structure body as try expression.
fun case_9(value: Int, value1: String, value2: String): Any { fun case_9(value_1: Int, value_2: String, value_3: String): Any {
return when (value) { return when (value_1) {
1 -> try { 4 } catch (e: Exception) { 5 } 1 -> try { 4 } catch (e: Exception) { 5 }
2 -> try { throw Exception() } catch (e: Exception) { value1 } 2 -> try { throw Exception() } catch (e: Exception) { value_2 }
else -> try { throw Exception() } catch (e: Exception) { {value2} } finally { } else -> try { throw Exception() } catch (e: Exception) { {value_3} } finally { }
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as elvis operator expression. // CASE DESCRIPTION: 'When' with control structure body as elvis operator expression.
fun case_10(value: Int, value1: String?, value2: String?) { fun case_10(value_1: Int, value_2: String?, value_3: String?) {
when (value) { when (value_1) {
1 -> value1 ?: true 1 -> value_2 ?: true
2 -> value1 ?: value2 ?: true 2 -> value_2 ?: value_3 ?: true
3 -> value1!! <!USELESS_ELVIS!>?: true<!> 3 -> value_2!! <!USELESS_ELVIS!>?: true<!>
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as range expression. // CASE DESCRIPTION: 'When' with control structure body as range expression.
fun case_11(value: Int) { fun case_11(value_1: Int) {
when (value) { when (value_1) {
1 -> 1..10 1 -> 1..10
2 -> -100L..100L 2 -> -100L..100L
3 -> -getInt()..getLong() 3 -> -getInt()..getLong()
@@ -147,75 +147,75 @@ fun case_11(value: Int) {
} }
// CASE DESCRIPTION: 'When' with control structure body as cast expression. // CASE DESCRIPTION: 'When' with control structure body as cast expression.
fun case_12(value: Int, value1: Collection<Int>, value2: Collection<Int>?) { fun case_12(value_1: Int, value_2: Collection<Int>, value_3: Collection<Int>?) {
when (value) { when (value_1) {
1 -> value1 as MutableList<Int> 1 -> value_2 as MutableList<Int>
2 -> value1 as? MutableList<Int> 2 -> value_2 as? MutableList<Int>
3 -> value2 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!> 3 -> value_3 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!>
4 -> (value1 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int> 4 -> (value_2 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int>
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as prefix operator expression. // CASE DESCRIPTION: 'When' with control structure body as prefix operator expression.
fun case_13(value: Int, value1: Int, value2: Int, value3: Boolean) { fun case_13(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean) {
var mutableValue1 = value1 var mutableValue1 = value_2
var mutableValue2 = value2 var mutableValue2 = value_3
when (value) { when (value_1) {
1 -> ++mutableValue1 1 -> ++mutableValue1
2 -> --mutableValue2 2 -> --mutableValue2
3 -> !value3 3 -> !value_4
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as postfix operator expression. // CASE DESCRIPTION: 'When' with control structure body as postfix operator expression.
fun case_14(value: Int, value1: Int, value2: Int, value3: Boolean?) { fun case_14(value_1: Int, value_2: Int, value_3: Int, value_4: Boolean?) {
var mutableValue1 = value1 var mutableValue1 = value_2
var mutableValue2 = value2 var mutableValue2 = value_3
when (value) { when (value_1) {
1 -> <!UNUSED_CHANGED_VALUE!>mutableValue1++<!> 1 -> <!UNUSED_CHANGED_VALUE!>mutableValue1++<!>
2 -> <!UNUSED_CHANGED_VALUE!>mutableValue2--<!> 2 -> <!UNUSED_CHANGED_VALUE!>mutableValue2--<!>
3 -> value3!! 3 -> value_4!!
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as indexing expression. // CASE DESCRIPTION: 'When' with control structure body as indexing expression.
fun case_15(value: Int, value1: List<Int>, value2: List<List<List<List<Int>>>>) { fun case_15(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>>>) {
when (value) { when (value_1) {
1 -> value1[0] 1 -> value_2[0]
2 -> value2[0][-4][1][-1] 2 -> value_3[0][-4][1][-1]
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as call expression. // CASE DESCRIPTION: 'When' with control structure body as call expression.
fun case_16(value: Int, value1: _Class, value2: _Class?, value3: Int) { fun case_16(value_1: Int, value_2: _Class, value_3: _Class?, value_4: Int) {
fun __fun_1(): () -> Unit { return fun() { } } fun __fun_1(): () -> Unit { return fun() { } }
when (value) { when (value_1) {
1 -> _funWithoutArgs() 1 -> _funWithoutArgs()
2 -> __fun_1()() 2 -> __fun_1()()
3 -> value1.fun_2(value3) 3 -> value_2.fun_2(value_4)
4 -> value2?.fun_2(value3) 4 -> value_3?.fun_2(value_4)
5 -> value2!!.fun_2(value3) 5 -> value_3!!.fun_2(value_4)
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as property access expression. // CASE DESCRIPTION: 'When' with control structure body as property access expression.
fun case_17(value: Int, value1: _Class, value2: _Class?) { fun case_17(value_1: Int, value_2: _Class, value_3: _Class?) {
when (value) { when (value_1) {
1 -> value1.prop_1 1 -> value_2.prop_1
2 -> value2?.prop_1 2 -> value_3?.prop_1
3 -> value1::prop_1.get() 3 -> value_2::prop_1.get()
4 -> value2!!::prop_3.get() 4 -> value_3!!::prop_3.get()
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as fun literal. // CASE DESCRIPTION: 'When' with control structure body as fun literal.
fun case_18(value: Int) { fun case_18(value_1: Int) {
val fun_1 = fun(): Int { return 0 } val fun_1 = fun(): Int { return 0 }
when (value) { when (value_1) {
1 -> fun() {} 1 -> fun() {}
2 -> fun(): Int { return 1 } 2 -> fun(): Int { return 1 }
3 -> fun(): () -> Unit { return fun() {} } 3 -> fun(): () -> Unit { return fun() {} }
@@ -224,10 +224,10 @@ fun case_18(value: Int) {
} }
// CASE DESCRIPTION: 'When' with control structure body as lambda literal. // CASE DESCRIPTION: 'When' with control structure body as lambda literal.
fun case_19(value: Int): Any { fun case_19(value_1: Int): Any {
val lambda_1 = { 0 } val lambda_1 = { 0 }
return when (value) { return when (value_1) {
1 -> lambda_1 1 -> lambda_1
2 -> { { {} } } 2 -> { { {} } }
else -> { -> (Int) else -> { -> (Int)
@@ -237,12 +237,12 @@ fun case_19(value: Int): Any {
} }
// CASE DESCRIPTION: 'When' with control structure body as object literal. // CASE DESCRIPTION: 'When' with control structure body as object literal.
fun case_20(value: Int) { fun case_20(value_1: Int) {
val object_1 = object { val object_1 = object {
val prop_1 = 1 val prop_1 = 1
} }
when (value) { when (value_1) {
1 -> object {} 1 -> object {}
2 -> object { 2 -> object {
private fun fun_1() { } private fun fun_1() { }
@@ -258,8 +258,8 @@ class A {
val lambda_1 = { 1 } val lambda_1 = { 1 }
fun fun_1(): Int { return 1 } fun fun_1(): Int { return 1 }
fun case_21(value: Int) { fun case_21(value_1: Int) {
when (value) { when (value_1) {
1 -> this 1 -> this
2 -> ((this)) 2 -> ((this))
3 -> this::prop_1.get() 3 -> this::prop_1.get()
@@ -273,24 +273,24 @@ class A {
} }
// CASE DESCRIPTION: 'When' with control structure body as throw expression. // CASE DESCRIPTION: 'When' with control structure body as throw expression.
fun case_22(value: Int) { fun case_22(value_1: Int) {
when (value) { when (value_1) {
1 -> throw Exception() 1 -> throw Exception()
2 -> throw throw throw Exception() 2 -> throw throw throw Exception()
} }
} }
// CASE DESCRIPTION: 'When' with control structure body as return expression. // CASE DESCRIPTION: 'When' with control structure body as return expression.
fun case_23(value: Int) { fun case_23(value_1: Int) {
fun r_1() { fun r_1() {
when (value) { when (value_1) {
1 -> return 1 -> return
2 -> <!UNREACHABLE_CODE!>return return<!> return 2 -> <!UNREACHABLE_CODE!>return return<!> return
} }
} }
fun r_2(): List<Int>? { fun r_2(): List<Int>? {
when (value) { when (value_1) {
1 -> return listOf(0, 1, 2) 1 -> return listOf(0, 1, 2)
2 -> return null 2 -> return null
} }
@@ -300,10 +300,10 @@ fun case_23(value: Int) {
} }
// CASE DESCRIPTION: 'When' with control structure body as continue expression. // CASE DESCRIPTION: 'When' with control structure body as continue expression.
fun case_24(value: Int) { fun case_24(value_1: Int) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
when (value) { when (value_1) {
1 -> continue@loop1 1 -> continue@loop1
2 -> continue@loop2 2 -> continue@loop2
} }
@@ -312,10 +312,10 @@ fun case_24(value: Int) {
} }
// CASE DESCRIPTION: 'When' with control structure body as break expression. // CASE DESCRIPTION: 'When' with control structure body as break expression.
fun case_25(value: Int) { fun case_25(value_1: Int) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
when (value) { when (value_1) {
1 -> break@loop1 1 -> break@loop1
2 -> break@loop2 2 -> break@loop2
} }
@@ -3,7 +3,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type. SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 1 NUMBER: 1
@@ -11,8 +11,8 @@
*/ */
// CASE DESCRIPTION: 'When' with custom class type test condition. // CASE DESCRIPTION: 'When' with custom class type test condition.
fun case_1(value: Any): String { fun case_1(value_1: Any): String {
when (value) { when (value_1) {
<!NO_COMPANION_OBJECT!>_EmptyClass<!> -> return "" <!NO_COMPANION_OBJECT!>_EmptyClass<!> -> return ""
} }
@@ -20,8 +20,8 @@ fun case_1(value: Any): String {
} }
// CASE DESCRIPTION: 'When' with Any type test condition. // CASE DESCRIPTION: 'When' with Any type test condition.
fun case_2(value: Any): String { fun case_2(value_1: Any): String {
when (value) { when (value_1) {
<!NO_COMPANION_OBJECT!>Any<!> -> return "" <!NO_COMPANION_OBJECT!>Any<!> -> return ""
} }
@@ -29,8 +29,8 @@ fun case_2(value: Any): String {
} }
// CASE DESCRIPTION: 'When' with Nothing type test condition. // CASE DESCRIPTION: 'When' with Nothing type test condition.
fun case_3(value: Any): String { fun case_3(value_1: Any): String {
when (value) { when (value_1) {
<!NO_COMPANION_OBJECT!>Nothing<!> -> return "" <!NO_COMPANION_OBJECT!>Nothing<!> -> return ""
} }
@@ -3,16 +3,16 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type. SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 2 NUMBER: 2
DESCRIPTION: 'When' with bound value and type test condition on the non-type operand of the type checking operator. DESCRIPTION: 'When' with bound value and type test condition on the non-type operand of the type checking operator.
*/ */
fun case_1(value: Any, <!UNUSED_PARAMETER!>value1<!>: Int): String { fun case_1(value_1: Any, <!UNUSED_PARAMETER!>value_2<!>: Int): String {
when (value) { when (value_1) {
is <!UNRESOLVED_REFERENCE!>value1<!> -> return "" is <!UNRESOLVED_REFERENCE!>value_2<!> -> return ""
} }
return "" return ""
@@ -3,17 +3,17 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression. SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 1 NUMBER: 1
DESCRIPTION: 'When' with bound value and 'when condition' with range expression, but without containment checking operator. DESCRIPTION: 'When' with bound value and 'when condition' with range expression, but without containment checking operator.
*/ */
fun case_1(value: Int, value1: _BasicTypesProvider): String { fun case_1(value_1: Int, value_2: _BasicTypesProvider): String {
when (value) { when (value_1) {
<!INCOMPATIBLE_TYPES!>-1000L..100<!> -> return "" <!INCOMPATIBLE_TYPES!>-1000L..100<!> -> return ""
<!INCOMPATIBLE_TYPES!>value1.getInt()..getLong()<!> -> return "" <!INCOMPATIBLE_TYPES!>value_2.getInt()..getLong()<!> -> return ""
} }
return "" return ""
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression. SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 2 NUMBER: 2
@@ -12,11 +12,11 @@
*/ */
// CASE DESCRIPTION: 'When' with values of types without defined contains operator. // CASE DESCRIPTION: 'When' with values of types without defined contains operator.
fun case_1(value: Int, value1: _EmptyClass, value2: Int, value3: Any): String { fun case_1(value_1: Int, value_2: _EmptyClass, value_3: Int, value_4: Any): String {
when (value) { when (value_1) {
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER, TYPE_MISMATCH_IN_RANGE!>in<!> value1 -> return "" <!UNRESOLVED_REFERENCE_WRONG_RECEIVER, TYPE_MISMATCH_IN_RANGE!>in<!> value_2 -> return ""
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER, TYPE_MISMATCH_IN_RANGE!>in<!> value2 -> return "" <!UNRESOLVED_REFERENCE_WRONG_RECEIVER, TYPE_MISMATCH_IN_RANGE!>in<!> value_3 -> return ""
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER, TYPE_MISMATCH_IN_RANGE!>in<!> value3 -> return "" <!UNRESOLVED_REFERENCE_WRONG_RECEIVER, TYPE_MISMATCH_IN_RANGE!>in<!> value_4 -> return ""
} }
return "" return ""
@@ -24,12 +24,12 @@ fun case_1(value: Int, value1: _EmptyClass, value2: Int, value3: Any): String {
/* /*
CASE DESCRIPTION: 'When' with values of Nothing (all existing contains operators used here). CASE DESCRIPTION: 'When' with values of Nothing (all existing contains operators used here).
UNEXPECTED BEHAVIOUR DISCUSSION
ISSUES: KT-25948 ISSUES: KT-25948
*/ */
fun case_2(value: Int, value3: Nothing) { fun case_2(value_1: Int, value_3: Nothing) {
when (value) { when (value_1) {
<!OVERLOAD_RESOLUTION_AMBIGUITY, TYPE_MISMATCH_IN_RANGE, UNREACHABLE_CODE!>in<!> value3 -> <!UNREACHABLE_CODE!>{}<!> <!OVERLOAD_RESOLUTION_AMBIGUITY, TYPE_MISMATCH_IN_RANGE, UNREACHABLE_CODE!>in<!> value_3 -> <!UNREACHABLE_CODE!>{}<!>
<!UNREACHABLE_CODE!><!OVERLOAD_RESOLUTION_AMBIGUITY, TYPE_MISMATCH_IN_RANGE!>in<!> throw Exception() -> {}<!> <!UNREACHABLE_CODE!><!OVERLOAD_RESOLUTION_AMBIGUITY, TYPE_MISMATCH_IN_RANGE!>in<!> throw Exception() -> {}<!>
<!UNREACHABLE_CODE!><!OVERLOAD_RESOLUTION_AMBIGUITY, TYPE_MISMATCH_IN_RANGE!>in<!> return -> {}<!> <!UNREACHABLE_CODE!><!OVERLOAD_RESOLUTION_AMBIGUITY, TYPE_MISMATCH_IN_RANGE!>in<!> return -> {}<!>
} }
@@ -3,7 +3,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [5] Any other expression. SENTENCE: [5] Any other expression.
NUMBER: 1 NUMBER: 1
@@ -11,24 +11,24 @@
*/ */
// CASE DESCRIPTION: 'When' with cycles in when condition. // CASE DESCRIPTION: 'When' with cycles in when condition.
fun case_1(value: Int, value1: List<Int>): String { fun case_1(value_1: Int, value_2: List<Int>): String {
when (value) { when (value_1) {
<!EXPRESSION_EXPECTED!>while (false) {}<!> -> return "" <!EXPRESSION_EXPECTED!>while (false) {}<!> -> return ""
<!EXPRESSION_EXPECTED!>do {} while (false)<!> -> return "" <!EXPRESSION_EXPECTED!>do {} while (false)<!> -> return ""
<!EXPRESSION_EXPECTED!>for (value2 in value1) {}<!> -> return "" <!EXPRESSION_EXPECTED!>for (value in value_2) {}<!> -> return ""
} }
return "" return ""
} }
// CASE DESCRIPTION: 'When' with assignments in when condition. // CASE DESCRIPTION: 'When' with assignments in when condition.
fun case_4(value: Int): String { fun case_4(value_1: Int): String {
var value1: Int var value_2: Int
var value2 = 10 var value_3 = 10
when (value) { when (value_1) {
<!ASSIGNMENT_IN_EXPRESSION_CONTEXT!>value1 = 10<!> -> return "" <!ASSIGNMENT_IN_EXPRESSION_CONTEXT!>value_2 = 10<!> -> return ""
<!ASSIGNMENT_IN_EXPRESSION_CONTEXT!>value2 %= 10<!> -> return "" <!ASSIGNMENT_IN_EXPRESSION_CONTEXT!>value_3 %= 10<!> -> return ""
} }
return "" return ""
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [5] Any other expression. SENTENCE: [5] Any other expression.
NUMBER: 2 NUMBER: 2
@@ -9,9 +9,9 @@
*/ */
// CASE DESCRIPTION: 'When' with break expression (without label). // CASE DESCRIPTION: 'When' with break expression (without label).
fun case_1(value: Int): String { fun case_1(value_1: Int): String {
while (true) { while (true) {
when (value) { when (value_1) {
<!BREAK_OR_CONTINUE_IN_WHEN!>break<!><!UNREACHABLE_CODE!><!> -> <!UNREACHABLE_CODE!>return ""<!> <!BREAK_OR_CONTINUE_IN_WHEN!>break<!><!UNREACHABLE_CODE!><!> -> <!UNREACHABLE_CODE!>return ""<!>
} }
} }
@@ -20,9 +20,9 @@ fun case_1(value: Int): String {
} }
// CASE DESCRIPTION: 'When' with continue expression (without label). // CASE DESCRIPTION: 'When' with continue expression (without label).
fun case_2(value: Int): String { fun case_2(value_1: Int): String {
while (true) { while (true) {
when (value) { when (value_1) {
<!BREAK_OR_CONTINUE_IN_WHEN!>continue<!><!UNREACHABLE_CODE!><!> -> <!UNREACHABLE_CODE!>return ""<!> <!BREAK_OR_CONTINUE_IN_WHEN!>continue<!><!UNREACHABLE_CODE!><!> -> <!UNREACHABLE_CODE!>return ""<!>
} }
} }
@@ -3,7 +3,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression. SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression.
NUMBER: 1 NUMBER: 1
@@ -11,21 +11,21 @@
*/ */
// CASE DESCRIPTION: 'When' with 'else' branch in the first position. // CASE DESCRIPTION: 'When' with 'else' branch in the first position.
fun case_1(value: Int): String = when (value) { fun case_1(value_1: Int): String = when (value_1) {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>1 -> ""<!> <!UNREACHABLE_CODE!>1 -> ""<!>
} }
// CASE DESCRIPTION: 'When' with 'else' branch in the middle position. // CASE DESCRIPTION: 'When' with 'else' branch in the middle position.
fun case_2(value: Int): String = when (value) { fun case_2(value_1: Int): String = when (value_1) {
1 -> "" 1 -> ""
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> ""
<!UNREACHABLE_CODE!>2 -> ""<!> <!UNREACHABLE_CODE!>2 -> ""<!>
} }
// CASE DESCRIPTION: 'When' with two 'else' branches. // CASE DESCRIPTION: 'When' with two 'else' branches.
fun case_3(value: Int): String { fun case_3(value_1: Int): String {
when (value) { when (value_1) {
<!ELSE_MISPLACED_IN_WHEN!>else<!> -> return "" <!ELSE_MISPLACED_IN_WHEN!>else<!> -> return ""
<!UNREACHABLE_CODE!>else -> return ""<!> <!UNREACHABLE_CODE!>else -> return ""<!>
} }
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type. SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 1 NUMBER: 1
@@ -12,8 +12,8 @@
*/ */
// CASE DESCRIPTION: 'When' with type test condition on the various basic types. // CASE DESCRIPTION: 'When' with type test condition on the various basic types.
fun case_1(value: Any): String { fun case_1(value_1: Any): String {
when (value) { when (value_1) {
is Int -> return "" is Int -> return ""
is Float -> return "" is Float -> return ""
is Double -> return "" is Double -> return ""
@@ -26,20 +26,20 @@ fun case_1(value: Any): String {
} }
// CASE DESCRIPTION: 'When' with type test condition on the various nullable basic types. // CASE DESCRIPTION: 'When' with type test condition on the various nullable basic types.
fun case_2(value: Any?): String = when (value) { fun case_2(value_1: Any?): String = when (value_1) {
is Int? -> "" // if value is null then this branch will be executed is Int? -> "" // if value is null then this branch will be executed
is Float -> "" is Float -> ""
else -> "" else -> ""
} }
// CASE DESCRIPTION: 'When' with 'else' branch and type test condition on Any. // CASE DESCRIPTION: 'When' with 'else' branch and type test condition on Any.
fun case_3(value: Any?): String = when (value) { fun case_3(value_1: Any?): String = when (value_1) {
is Any -> "" is Any -> ""
else -> "" else -> ""
} }
// CASE DESCRIPTION: 'When' with 'else' branch and type test condition on nullable (redundant) Any. // CASE DESCRIPTION: 'When' with 'else' branch and type test condition on nullable (redundant) Any.
fun case_4(value: Any): String = when (value) { fun case_4(value_1: Any): String = when (value_1) {
<!USELESS_IS_CHECK!>is Any<!USELESS_NULLABLE_CHECK!>?<!><!> -> "" <!USELESS_IS_CHECK!>is Any<!USELESS_NULLABLE_CHECK!>?<!><!> -> ""
else -> "" else -> ""
} }
@@ -49,7 +49,7 @@ fun case_4(value: Any): String = when (value) {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-22996 ISSUES: KT-22996
*/ */
fun case_5(value: Any?): String = when (value) { fun case_5(value_1: Any?): String = when (value_1) {
is Double -> "" is Double -> ""
is Int? -> "" // if value is null then this branch will be executed is Int? -> "" // if value is null then this branch will be executed
is String -> "" is String -> ""
@@ -60,8 +60,8 @@ fun case_5(value: Any?): String = when (value) {
} }
// CASE DESCRIPTION: 'When' with type test condition on the objetcs. // CASE DESCRIPTION: 'When' with type test condition on the objetcs.
fun case_6(value: Any): String { fun case_6(value_1: Any): String {
when (value) { when (value_1) {
is _EmptyObject -> return "" is _EmptyObject -> return ""
is _ClassWithCompanionObject.Companion -> return "" is _ClassWithCompanionObject.Companion -> return ""
} }
@@ -5,7 +5,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type. SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 2 NUMBER: 2
@@ -13,7 +13,7 @@
*/ */
// CASE DESCRIPTION: 'When' in which all branches includes invert type checking operators. // CASE DESCRIPTION: 'When' in which all branches includes invert type checking operators.
fun case_1(value: _SealedClass) = when (value) { fun case_1(value_1: _SealedClass) = when (value_1) {
!is _SealedChild1 -> {} !is _SealedChild1 -> {}
!is _SealedChild2 -> {} !is _SealedChild2 -> {}
!is _SealedChild3 -> {} !is _SealedChild3 -> {}
@@ -24,14 +24,14 @@ fun case_1(value: _SealedClass) = when (value) {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-22996 ISSUES: KT-22996
*/ */
fun case_2(value: _SealedClass?): String = when (value) { fun case_2(value_1: _SealedClass?): String = when (value_1) {
!is _SealedChild2 -> "" // including null !is _SealedChild2 -> "" // including null
<!USELESS_IS_CHECK!>is _SealedChild2<!> -> "" <!USELESS_IS_CHECK!>is _SealedChild2<!> -> ""
null -> "" // redundant null -> "" // redundant
} }
// CASE DESCRIPTION: 'When' with direct and invert type checking operators on the same types and null-check. // CASE DESCRIPTION: 'When' with direct and invert type checking operators on the same types and null-check.
fun case_3(value: _SealedClass?): String = when (value) { fun case_3(value_1: _SealedClass?): String = when (value_1) {
!is _SealedChild2? -> "" // null isn't included !is _SealedChild2? -> "" // null isn't included
is _SealedChild2 -> "" is _SealedChild2 -> ""
null -> "" null -> ""
@@ -42,16 +42,16 @@ fun case_3(value: _SealedClass?): String = when (value) {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-22996 ISSUES: KT-22996
*/ */
fun case_4(value: _SealedClass?) { fun case_4(value_1: _SealedClass?) {
when (value) { when (value_1) {
!is _SealedChild2 -> {} // including null !is _SealedChild2 -> {} // including null
<!USELESS_IS_CHECK!>is _SealedChild2?<!> -> {} // redundant nullable type check <!USELESS_IS_CHECK!>is _SealedChild2?<!> -> {} // redundant nullable type check
} }
} }
// CASE DESCRIPTION: 'When' with direct and invert type checking operator on the objects. // CASE DESCRIPTION: 'When' with direct and invert type checking operator on the objects.
fun case_5(value: Any): String { fun case_5(value_1: Any): String {
when (value) { when (value_1) {
is _EmptyObject -> return "" is _EmptyObject -> return ""
!is _ClassWithCompanionObject.Companion -> return "" !is _ClassWithCompanionObject.Companion -> return ""
} }
@@ -5,7 +5,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type. SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 3 NUMBER: 3
@@ -13,7 +13,7 @@
*/ */
// CASE DESCRIPTION: 'When' with type test condition on the various basic types. // CASE DESCRIPTION: 'When' with type test condition on the various basic types.
fun case_1(value: Any) = when (value) { fun case_1(value_1: Any) = when (value_1) {
is Int -> {} is Int -> {}
is Float, is Char, is Boolean -> {} is Float, is Char, is Boolean -> {}
is String -> {} is String -> {}
@@ -21,7 +21,7 @@ fun case_1(value: Any) = when (value) {
} }
// CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types. // CASE DESCRIPTION: 'When' with 'else' branch and type test condition on the various nullable basic types.
fun case_2(value: Any?) = when (value) { fun case_2(value_1: Any?) = when (value_1) {
is Float, is Char, is _SealedClass? -> "" // if value is null then this branch will be executed is Float, is Char, is _SealedClass? -> "" // if value is null then this branch will be executed
is Double, is Boolean, is _ClassWithCompanionObject.Companion -> "" is Double, is Boolean, is _ClassWithCompanionObject.Companion -> ""
else -> "" else -> ""
@@ -32,7 +32,7 @@ fun case_2(value: Any?) = when (value) {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-22996 ISSUES: KT-22996
*/ */
fun case_3(value: Any?) = when (value) { fun case_3(value_1: Any?) = when (value_1) {
is Float, is Char, is Int? -> "" // if value is null then this branch will be executed is Float, is Char, is Int? -> "" // if value is null then this branch will be executed
is _SealedChild2, is Boolean?, is String -> "" // redundant nullable type check is _SealedChild2, is Boolean?, is String -> "" // redundant nullable type check
else -> "" else -> ""
@@ -43,7 +43,7 @@ fun case_3(value: Any?) = when (value) {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-22996 ISSUES: KT-22996
*/ */
fun case_4(value: Any?) = when (value) { fun case_4(value_1: Any?) = when (value_1) {
is Float, is Char?, is Int? -> "" // double nullable type check in the one branch is Float, is Char?, is Int? -> "" // double nullable type check in the one branch
is _SealedChild1, is Boolean, is String -> "" is _SealedChild1, is Boolean, is String -> ""
else -> "" else -> ""
@@ -54,8 +54,8 @@ fun case_4(value: Any?) = when (value) {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-22996 ISSUES: KT-22996
*/ */
fun case_5(value: Any?): String { fun case_5(value_1: Any?): String {
when (value) { when (value_1) {
is Float, is Char?, is Int -> return "" is Float, is Char?, is Int -> return ""
is Double, is _EmptyObject, is String -> return "" is Double, is _EmptyObject, is String -> return ""
null -> return "" // null-check redundant null -> return "" // null-check redundant
@@ -68,8 +68,8 @@ fun case_5(value: Any?): String {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-22996 ISSUES: KT-22996
*/ */
fun case_6(value: Any?): String { fun case_6(value_1: Any?): String {
when (value) { when (value_1) {
is Float, is Char?, null, is Int -> return "" // double nullable type check in the one branch is Float, is Char?, null, is Int -> return "" // double nullable type check in the one branch
is Double, is _EmptyObject, is String -> return "" is Double, is _EmptyObject, is String -> return ""
else -> return "" else -> return ""
@@ -3,7 +3,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [1] Type test condition: type checking operator followed by type. SENTENCE: [1] Type test condition: type checking operator followed by type.
NUMBER: 4 NUMBER: 4
@@ -11,28 +11,28 @@
*/ */
// CASE DESCRIPTION: 'When' with direct and invert type checking operator in the one branch and other branch. // CASE DESCRIPTION: 'When' with direct and invert type checking operator in the one branch and other branch.
fun case_1(value: _SealedClass): String = when (value) { fun case_1(value_1: _SealedClass): String = when (value_1) {
is _SealedChild1, !is _SealedChild3 -> "" is _SealedChild1, !is _SealedChild3 -> ""
<!USELESS_IS_CHECK!>is _SealedChild3<!> -> "" <!USELESS_IS_CHECK!>is _SealedChild3<!> -> ""
} }
// CASE DESCRIPTION: 'When' with three invert type checking operator in the one branch. // CASE DESCRIPTION: 'When' with three invert type checking operator in the one branch.
fun case_2(value: _SealedClass) = when (value) { fun case_2(value_1: _SealedClass) = when (value_1) {
!is _SealedChild1, !is _SealedChild2, !is _SealedChild3 -> {} !is _SealedChild1, !is _SealedChild2, !is _SealedChild3 -> {}
} }
// CASE DESCRIPTION: 'When' with direct (first) and invert (second) type checking operator on the some type in the one branch. // CASE DESCRIPTION: 'When' with direct (first) and invert (second) type checking operator on the some type in the one branch.
fun case_3(value: _SealedClass): String = when (value) { fun case_3(value_1: _SealedClass): String = when (value_1) {
is _SealedChild2, !is _SealedChild2 -> "" is _SealedChild2, !is _SealedChild2 -> ""
} }
// CASE DESCRIPTION: 'When' with direct (second) and invert (first) type checking operator in the one branch. // CASE DESCRIPTION: 'When' with direct (second) and invert (first) type checking operator in the one branch.
fun case_4(value: _SealedClass): String = when (value) { fun case_4(value_1: _SealedClass): String = when (value_1) {
!is _SealedChild1, <!USELESS_IS_CHECK!>is _SealedChild1<!> -> "" !is _SealedChild1, <!USELESS_IS_CHECK!>is _SealedChild1<!> -> ""
} }
// CASE DESCRIPTION: 'When' with direct and invert (nullable) type checking operator on the some type in the one branch. // CASE DESCRIPTION: 'When' with direct and invert (nullable) type checking operator on the some type in the one branch.
fun case_5(value: Any?): String = when (value) { fun case_5(value_1: Any?): String = when (value_1) {
is _SealedChild3, !is _SealedChild3? -> "" is _SealedChild3, !is _SealedChild3? -> ""
else -> "" else -> ""
} }
@@ -42,7 +42,7 @@ fun case_5(value: Any?): String = when (value) {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-22996 ISSUES: KT-22996
*/ */
fun case_6(value: Any?): String = when (value) { fun case_6(value_1: Any?): String = when (value_1) {
is Boolean?, !is _SealedChild3 -> "" // double nullable type check in the one branch is Boolean?, !is _SealedChild3 -> "" // double nullable type check in the one branch
<!USELESS_IS_CHECK!>is _SealedChild3<!> -> "" <!USELESS_IS_CHECK!>is _SealedChild3<!> -> ""
else -> "" else -> ""
@@ -53,7 +53,7 @@ fun case_6(value: Any?): String = when (value) {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-22996 ISSUES: KT-22996
*/ */
fun case_7(value: Any?): String = when (value) { fun case_7(value_1: Any?): String = when (value_1) {
is Number?, null, !is _SealedChild3 -> "" // triple nullable type check in the one branch is Number?, null, !is _SealedChild3 -> "" // triple nullable type check in the one branch
else -> "" else -> ""
} }
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression. SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 1 NUMBER: 1
@@ -12,21 +12,21 @@
*/ */
// CASE DESCRIPTION: 'When' with range operator. // CASE DESCRIPTION: 'When' with range operator.
fun case_1(value: Int, value1: Int, value2: Short): String { fun case_1(value_1: Int, value_2: Int, value_3: Short): String {
when (value) { when (value_1) {
in Long.MIN_VALUE..-100 -> return "" in Long.MIN_VALUE..-100 -> return ""
in -99..0 -> return "" in -99..0 -> return ""
!in 100.toByte()..value1 -> return "" !in 100.toByte()..value_2 -> return ""
in value1..value2 -> return "" in value_2..value_3 -> return ""
} }
return "" return ""
} }
// CASE DESCRIPTION: 'When' on types with contains method defined. // CASE DESCRIPTION: 'When' on types with contains method defined.
fun case_2(value: Int, value1: List<IntArray>, value2: _Class) = when (value) { fun case_2(value_1: Int, value_2: List<IntArray>, value_3: _Class) = when (value_1) {
in value1[0] -> "" in value_2[0] -> ""
!in listOf(0, 1, 2, 3, 4) -> "" !in listOf(0, 1, 2, 3, 4) -> ""
!in value2.getIntArray(90) -> "" !in value_3.getIntArray(90) -> ""
else -> "" else -> ""
} }
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [3] Contains test condition: containment operator followed by an expression. SENTENCE: [3] Contains test condition: containment operator followed by an expression.
NUMBER: 2 NUMBER: 2
@@ -12,17 +12,17 @@
*/ */
// CASE DESCRIPTION: 'When' with range operator. // CASE DESCRIPTION: 'When' with range operator.
fun case_1(value: Int, value1: Int, value2: Short): String { fun case_1(value_1: Int, value_2: Int, value_3: Short): String {
when (value) { when (value_1) {
in Long.MIN_VALUE..-100, in -99..0 -> return "" in Long.MIN_VALUE..-100, in -99..0 -> return ""
!in 100.toByte()..value1, in value1..value2 -> return "" !in 100.toByte()..value_2, in value_2..value_3 -> return ""
} }
return "" return ""
} }
// CASE DESCRIPTION: 'When' on types with contains method defined. // CASE DESCRIPTION: 'When' on types with contains method defined.
fun case_2(value: Int, value1: List<IntArray>, value2: _Class) = when (value) { fun case_2(value_1: Int, value_2: List<IntArray>, value_3: _Class) = when (value_1) {
!in value1[0], !in listOf(0, 1, 2, 3, 4), !in value2.getIntArray(90) -> "" !in value_2[0], !in listOf(0, 1, 2, 3, 4), !in value_3.getIntArray(90) -> ""
else -> "" else -> ""
} }
@@ -5,7 +5,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [5] Any other expression. SENTENCE: [5] Any other expression.
NUMBER: 1 NUMBER: 1
@@ -13,8 +13,8 @@
*/ */
// CASE DESCRIPTION: 'When' with condition as literals. // CASE DESCRIPTION: 'When' with condition as literals.
fun case_1(value: Any?) { fun case_1(value_1: Any?) {
when (value) { when (value_1) {
true -> {} true -> {}
100 -> {} 100 -> {}
-.09f -> {} -.09f -> {}
@@ -25,48 +25,48 @@ fun case_1(value: Any?) {
} }
// CASE DESCRIPTION: 'When' with condition as arithmetic expressions. // CASE DESCRIPTION: 'When' with condition as arithmetic expressions.
fun case_2(value: Number, value1: Int) { fun case_2(value_1: Number, value_2: Int) {
when (value) { when (value_1) {
-.09 % 10L -> {} -.09 % 10L -> {}
value1 / -5 -> {} value_2 / -5 -> {}
getByte(99) - 11 + 90 -> {} getByte(99) - 11 + 90 -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as boolean expressions (logical, equality and comparison). // CASE DESCRIPTION: 'When' with condition as boolean expressions (logical, equality and comparison).
fun case_3(value: Boolean, value1: Boolean, value2: Long) { fun case_3(value_1: Boolean, value_2: Boolean, value_3: Long) {
when (value) { when (value_1) {
value1 -> {} value_2 -> {}
!value1 -> {} !value_2 -> {}
getBoolean() && value1 -> {} getBoolean() && value_2 -> {}
getChar(10) != 'a' -> {} getChar(10) != 'a' -> {}
getList() === getAny() -> {} getList() === getAny() -> {}
value2 <= 11 -> {} value_3 <= 11 -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as concatenations. // CASE DESCRIPTION: 'When' with condition as concatenations.
fun case_4(value: String, value1: String, value2: String) { fun case_4(value_1: String, value_2: String, value_3: String) {
when (value) { when (value_1) {
"..." + value1 + "" + "$value2" + "..." -> {} "..." + value_2 + "" + "$value_3" + "..." -> {}
value1 + getString() -> {} value_2 + getString() -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as when expression. // CASE DESCRIPTION: 'When' with condition as when expression.
fun case_5(value: Int, value1: Int, value2: Boolean?) { fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
when (value) { when (value_1) {
when { when {
value1 > 1000 -> 1 value_2 > 1000 -> 1
value1 > 100 -> 2 value_2 > 100 -> 2
else -> 3 else -> 3
} -> {} } -> {}
when (value2) { when (value_3) {
true -> 1 true -> 1
false -> 2 false -> 2
null -> 3 null -> 3
} -> {} } -> {}
when (value2!!) { when (value_3!!) {
true -> 1 true -> 1
false -> 2 false -> 2
} -> {} } -> {}
@@ -74,37 +74,37 @@ fun case_5(value: Int, value1: Int, value2: Boolean?) {
} }
// CASE DESCRIPTION: 'When' with condition as if expression. // CASE DESCRIPTION: 'When' with condition as if expression.
fun case_6(value: Int, value1: Int) { fun case_6(value_1: Int, value_2: Int) {
when (value) { when (value_1) {
if (value1 > 1000) 1 if (value_2 > 1000) 1
else 2 -> {} else 2 -> {}
if (value1 < 100) 1 if (value_2 < 100) 1
else if (value1 < 10) 2 else if (value_2 < 10) 2
else 3 -> {} else 3 -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as try expression. // CASE DESCRIPTION: 'When' with condition as try expression.
fun case_7(value: Any, value1: String, value2: String) { fun case_7(value_1: Any, value_2: String, value_3: String) {
when (value) { when (value_1) {
try { 4 } catch (e: Exception) { 5 } -> {} try { 4 } catch (e: Exception) { 5 } -> {}
try { throw Exception() } catch (e: Exception) { value1 } -> {} try { throw Exception() } catch (e: Exception) { value_2 } -> {}
try { throw Exception() } catch (e: Exception) { {value2} } finally { } -> {} try { throw Exception() } catch (e: Exception) { {value_3} } finally { } -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as elvis operator expression. // CASE DESCRIPTION: 'When' with condition as elvis operator expression.
fun case_8(value: Int, value1: Int?, value2: Int?) { fun case_8(value_1: Int, value_2: Int?, value_3: Int?) {
when (value) { when (value_1) {
value1 ?: 0 -> {} value_2 ?: 0 -> {}
value1 ?: value2 ?: 0 -> {} value_2 ?: value_3 ?: 0 -> {}
value1!! <!USELESS_ELVIS!>?: 0<!> -> {} value_2!! <!USELESS_ELVIS!>?: 0<!> -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as range expression. // CASE DESCRIPTION: 'When' with condition as range expression.
fun case_9(value: Any) { fun case_9(value_1: Any) {
when (value) { when (value_1) {
1..10 -> {} 1..10 -> {}
-100L..100L -> {} -100L..100L -> {}
-getInt()..getLong() -> {} -getInt()..getLong() -> {}
@@ -112,75 +112,75 @@ fun case_9(value: Any) {
} }
// CASE DESCRIPTION: 'When' with condition as cast expression. // CASE DESCRIPTION: 'When' with condition as cast expression.
fun case_10(value: Collection<Int>, value1: Collection<Int>, value2: Collection<Int>?) { fun case_10(value_1: Collection<Int>, value_2: Collection<Int>, value_3: Collection<Int>?) {
when (value) { when (value_1) {
value1 as MutableList<Int> -> {} value_2 as MutableList<Int> -> {}
value1 <!USELESS_CAST!>as? MutableList<Int><!> -> {} value_2 <!USELESS_CAST!>as? MutableList<Int><!> -> {}
value2 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!> -> {} value_3 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!> -> {}
(value1 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int> -> {} (value_2 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int> -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as prefix operator expression. // CASE DESCRIPTION: 'When' with condition as prefix operator expression.
fun case_11(value: Any, value1: Int, value2: Int, value3: Boolean) { fun case_11(value_1: Any, value_2: Int, value_3: Int, value_4: Boolean) {
var mutableValue1 = value1 var mutableValue1 = value_2
var mutableValue2 = value2 var mutableValue2 = value_3
when (value) { when (value_1) {
++mutableValue1 -> {} ++mutableValue1 -> {}
--mutableValue2 -> {} --mutableValue2 -> {}
!value3 -> {} !value_4 -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as postfix operator expression. // CASE DESCRIPTION: 'When' with condition as postfix operator expression.
fun case_12(value: Int, value1: Int, value2: Int, value3: Int?) { fun case_12(value_1: Int, value_2: Int, value_3: Int, value_4: Int?) {
var mutableValue1 = value1 var mutableValue1 = value_2
var mutableValue2 = value2 var mutableValue2 = value_3
when (value) { when (value_1) {
<!UNUSED_CHANGED_VALUE!>mutableValue1++<!> -> {} <!UNUSED_CHANGED_VALUE!>mutableValue1++<!> -> {}
<!UNUSED_CHANGED_VALUE!>mutableValue2--<!> -> {} <!UNUSED_CHANGED_VALUE!>mutableValue2--<!> -> {}
value3!! -> {} value_4!! -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as indexing expression. // CASE DESCRIPTION: 'When' with condition as indexing expression.
fun case_13(value: Int, value1: List<Int>, value2: List<List<List<List<Int>>>>) { fun case_13(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>>>) {
when (value) { when (value_1) {
value1[0] -> {} value_2[0] -> {}
value2[0][-4][1][-1] -> {} value_3[0][-4][1][-1] -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as call expression. // CASE DESCRIPTION: 'When' with condition as call expression.
fun case_14(value: Any, value1: _Class, value2: _Class?, value3: Int) { fun case_14(value_1: Any, value_2: _Class, value_3: _Class?, value_4: Int) {
fun __fun_1(): () -> Any { return fun() { } } fun __fun_1(): () -> Any { return fun() { } }
when (value) { when (value_1) {
_funWithoutArgs() -> {} _funWithoutArgs() -> {}
__fun_1()() -> {} __fun_1()() -> {}
value1.fun_2(value3) -> {} value_2.fun_2(value_4) -> {}
value2?.fun_2(value3) -> {} value_3?.fun_2(value_4) -> {}
value2!!.fun_2(value3) -> {} value_3!!.fun_2(value_4) -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as property access expression. // CASE DESCRIPTION: 'When' with condition as property access expression.
fun case_15(value: Int, value1: _Class, value2: _Class?) { fun case_15(value_1: Int, value_2: _Class, value_3: _Class?) {
when (value) { when (value_1) {
value1.prop_1 -> {} value_2.prop_1 -> {}
value2?.prop_2 -> {} value_3?.prop_2 -> {}
value1::prop_1.get() -> {} value_2::prop_1.get() -> {}
value2!!::prop_3.get() -> {} value_3!!::prop_3.get() -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as fun literal. // CASE DESCRIPTION: 'When' with condition as fun literal.
fun case_16(value: () -> Any): Any { fun case_16(value_1: () -> Any): Any {
val fun_1 = fun() { return } val fun_1 = fun() { return }
return when (value) { return when (value_1) {
fun() {} -> {} fun() {} -> {}
fun() { return } -> {} fun() { return } -> {}
fun(): () -> Unit { return fun() {} } -> {} fun(): () -> Unit { return fun() {} } -> {}
@@ -190,10 +190,10 @@ fun case_16(value: () -> Any): Any {
} }
// CASE DESCRIPTION: 'When' with condition as lambda literal. // CASE DESCRIPTION: 'When' with condition as lambda literal.
fun case_17(value: () -> Any) { fun case_17(value_1: () -> Any) {
val lambda_1 = { 0 } val lambda_1 = { 0 }
when (value) { when (value_1) {
lambda_1 -> {} lambda_1 -> {}
{ { {} } } -> {} { { {} } } -> {}
{ -> (Int) { -> (Int)
@@ -203,12 +203,12 @@ fun case_17(value: () -> Any) {
} }
// CASE DESCRIPTION: 'When' with condition as object literal. // CASE DESCRIPTION: 'When' with condition as object literal.
fun case_18(value: Any) { fun case_18(value_1: Any) {
val object_1 = object { val object_1 = object {
val prop_1 = 1 val prop_1 = 1
} }
when (value) { when (value_1) {
object {} -> {} object {} -> {}
object { object {
private fun fun_1() { } private fun fun_1() { }
@@ -224,8 +224,8 @@ class A {
val lambda_1 = { 1 } val lambda_1 = { 1 }
fun fun_1(): Int { return 1 } fun fun_1(): Int { return 1 }
fun case_19(value: Any) { fun case_19(value_1: Any) {
when (value) { when (value_1) {
this -> {} this -> {}
((this)) -> {} ((this)) -> {}
this::prop_1.get() -> {} this::prop_1.get() -> {}
@@ -239,24 +239,24 @@ class A {
} }
// CASE DESCRIPTION: 'When' with condition as throw expression. // CASE DESCRIPTION: 'When' with condition as throw expression.
fun case_20(value: Nothing) { fun case_20(value_1: Nothing) {
when (value) { when (value_1) {
<!UNREACHABLE_CODE!>throw Exception() -> {}<!> <!UNREACHABLE_CODE!>throw Exception() -> {}<!>
<!UNREACHABLE_CODE!>throw throw throw Exception() -> {}<!> <!UNREACHABLE_CODE!>throw throw throw Exception() -> {}<!>
} }
} }
// CASE DESCRIPTION: 'When' with condition as return expression. // CASE DESCRIPTION: 'When' with condition as return expression.
fun case_21(value: Nothing) { fun case_21(value_1: Nothing) {
fun r_1() { fun r_1() {
when (value) { when (value_1) {
<!UNREACHABLE_CODE!>return -> 1<!> <!UNREACHABLE_CODE!>return -> 1<!>
<!UNREACHABLE_CODE!>return return return -> 2<!> <!UNREACHABLE_CODE!>return return return -> 2<!>
} }
} }
fun r_2(): List<Int>? { fun r_2(): List<Int>? {
when (value) { when (value_1) {
<!UNREACHABLE_CODE!>return listOf(0, 1, 2) -> 1<!> <!UNREACHABLE_CODE!>return listOf(0, 1, 2) -> 1<!>
<!UNREACHABLE_CODE!>return null -> 2<!> <!UNREACHABLE_CODE!>return null -> 2<!>
} }
@@ -264,10 +264,10 @@ fun case_21(value: Nothing) {
} }
// CASE DESCRIPTION: 'When' with condition as continue expression. // CASE DESCRIPTION: 'When' with condition as continue expression.
fun case_22(value: Nothing) { fun case_22(value_1: Nothing) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
when (value) { when (value_1) {
<!UNREACHABLE_CODE!>continue@loop1 -> 1<!> <!UNREACHABLE_CODE!>continue@loop1 -> 1<!>
<!UNREACHABLE_CODE!>continue@loop2 -> 2<!> <!UNREACHABLE_CODE!>continue@loop2 -> 2<!>
} }
@@ -276,10 +276,10 @@ fun case_22(value: Nothing) {
} }
// CASE DESCRIPTION: 'When' with condition as break expression. // CASE DESCRIPTION: 'When' with condition as break expression.
fun case_23(value: Nothing) { fun case_23(value_1: Nothing) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
when (value) { when (value_1) {
<!UNREACHABLE_CODE!>break@loop1 -> 1<!> <!UNREACHABLE_CODE!>break@loop1 -> 1<!>
<!UNREACHABLE_CODE!>break@loop2 -> 2<!> <!UNREACHABLE_CODE!>break@loop2 -> 2<!>
} }
@@ -5,7 +5,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [5] Any other expression. SENTENCE: [5] Any other expression.
NUMBER: 2 NUMBER: 2
@@ -13,47 +13,47 @@
*/ */
// CASE DESCRIPTION: 'When' with condition as literals. // CASE DESCRIPTION: 'When' with condition as literals.
fun case_1(value: Any?) { fun case_1(value_1: Any?) {
when (value) { when (value_1) {
true, 100, -.09f -> {} true, 100, -.09f -> {}
'.', "...", null -> {} '.', "...", null -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as arithmetic expressions. // CASE DESCRIPTION: 'When' with condition as arithmetic expressions.
fun case_2(value: Number, value1: Int) { fun case_2(value_1: Number, value_2: Int) {
when (value) { when (value_1) {
-.09 % 10L, value1 / -5, getByte(99) - 11 + 90 -> {} -.09 % 10L, value_2 / -5, getByte(99) - 11 + 90 -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as boolean expressions (logical, equality and comparison). // CASE DESCRIPTION: 'When' with condition as boolean expressions (logical, equality and comparison).
fun case_3(value: Boolean, value1: Boolean, value2: Long) { fun case_3(value_1: Boolean, value_2: Boolean, value_3: Long) {
when (value) { when (value_1) {
value1, !value1, getBoolean() && value1, getChar(10) != 'a' -> {} value_2, !value_2, getBoolean() && value_2, getChar(10) != 'a' -> {}
getList() === getAny(), value2 <= 11 -> {} getList() === getAny(), value_3 <= 11 -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as concatenations. // CASE DESCRIPTION: 'When' with condition as concatenations.
fun case_4(value: String, value1: String, value2: String) { fun case_4(value_1: String, value_2: String, value_3: String) {
when (value) { when (value_1) {
"..." + value1 + "" + "$value2" + "...", value1 + getString() -> {} "..." + value_2 + "" + "$value_3" + "...", value_2 + getString() -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as when expression. // CASE DESCRIPTION: 'When' with condition as when expression.
fun case_5(value: Int, value1: Int, value2: Boolean?) { fun case_5(value_1: Int, value_2: Int, value_3: Boolean?) {
when (value) { when (value_1) {
when { when {
value1 > 1000 -> 1 value_2 > 1000 -> 1
value1 > 100 -> 2 value_2 > 100 -> 2
else -> 3 else -> 3
}, when (value2) { }, when (value_3) {
true -> 1 true -> 1
false -> 2 false -> 2
null -> 3 null -> 3
}, when (value2!!) { }, when (value_3!!) {
true -> 1 true -> 1
false -> 2 false -> 2
} -> {} } -> {}
@@ -61,113 +61,113 @@ fun case_5(value: Int, value1: Int, value2: Boolean?) {
} }
// CASE DESCRIPTION: 'When' with condition as if expression. // CASE DESCRIPTION: 'When' with condition as if expression.
fun case_6(value: Int, value1: Int) { fun case_6(value_1: Int, value_2: Int) {
when (value) { when (value_1) {
if (value1 > 1000) 1 else 2, if (value1 < 100) 1 else if (value1 < 10) 2 else 3 -> {} if (value_2 > 1000) 1 else 2, if (value_2 < 100) 1 else if (value_2 < 10) 2 else 3 -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as try expression. // CASE DESCRIPTION: 'When' with condition as try expression.
fun case_7(value: Any, value1: String, value2: String) { fun case_7(value_1: Any, value_2: String, value_3: String) {
when (value) { when (value_1) {
try { 4 } catch (e: Exception) { 5 }, try { throw Exception() } catch (e: Exception) { value1 }, try { throw Exception() } catch (e: Exception) { {value2} } finally { } -> {} try { 4 } catch (e: Exception) { 5 }, try { throw Exception() } catch (e: Exception) { value_2 }, try { throw Exception() } catch (e: Exception) { {value_3} } finally { } -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as elvis operator expression. // CASE DESCRIPTION: 'When' with condition as elvis operator expression.
fun case_8(value: Int, value1: Int?, value2: Int?) { fun case_8(value_1: Int, value_2: Int?, value_3: Int?) {
when (value) { when (value_1) {
value1 ?: 0, value1 ?: value2 ?: 0, value1!! <!USELESS_ELVIS!>?: 0<!> -> {} value_2 ?: 0, value_2 ?: value_3 ?: 0, value_2!! <!USELESS_ELVIS!>?: 0<!> -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as range expression. // CASE DESCRIPTION: 'When' with condition as range expression.
fun case_9(value: Any) { fun case_9(value_1: Any) {
when (value) { when (value_1) {
1..10, -100L..100L, -getInt()..getLong() -> {} 1..10, -100L..100L, -getInt()..getLong() -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as cast expression. // CASE DESCRIPTION: 'When' with condition as cast expression.
fun case_10(value: Collection<Int>, value1: Collection<Int>, value2: Collection<Int>?) { fun case_10(value_1: Collection<Int>, value_2: Collection<Int>, value_3: Collection<Int>?) {
when (value) { when (value_1) {
value1 as MutableList<Int>, value1 <!USELESS_CAST!>as? MutableList<Int><!> -> {} value_2 as MutableList<Int>, value_2 <!USELESS_CAST!>as? MutableList<Int><!> -> {}
value2 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!>, (value1 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int> -> {} value_3 <!UNCHECKED_CAST!>as? MutableMap<Int, Int><!>, (value_2 <!UNCHECKED_CAST!>as? Map<Int, Int><!>) as MutableMap<Int, Int> -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as prefix operator expression. // CASE DESCRIPTION: 'When' with condition as prefix operator expression.
fun case_11(value: Any, value1: Int, value2: Int, value3: Boolean) { fun case_11(value_1: Any, value_2: Int, value_3: Int, value_4: Boolean) {
var mutableValue1 = value1 var mutableValue1 = value_2
var mutableValue2 = value2 var mutableValue2 = value_3
when (value) { when (value_1) {
++mutableValue1, --mutableValue2, !value3 -> {} ++mutableValue1, --mutableValue2, !value_4 -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as postfix operator expression. // CASE DESCRIPTION: 'When' with condition as postfix operator expression.
fun case_12(value: Int, value1: Int, value2: Int, value3: Int?) { fun case_12(value_1: Int, value_2: Int, value_3: Int, value_4: Int?) {
var mutableValue1 = value1 var mutableValue1 = value_2
var mutableValue2 = value2 var mutableValue2 = value_3
when (value) { when (value_1) {
<!UNUSED_CHANGED_VALUE!>mutableValue1++<!>, <!UNUSED_CHANGED_VALUE!>mutableValue2--<!>, value3!! -> {} <!UNUSED_CHANGED_VALUE!>mutableValue1++<!>, <!UNUSED_CHANGED_VALUE!>mutableValue2--<!>, value_4!! -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as indexing expression. // CASE DESCRIPTION: 'When' with condition as indexing expression.
fun case_13(value: Int, value1: List<Int>, value2: List<List<List<List<Int>>>>) { fun case_13(value_1: Int, value_2: List<Int>, value_3: List<List<List<List<Int>>>>) {
when (value) { when (value_1) {
value1[0], value2[0][-4][1][-1] -> {} value_2[0], value_3[0][-4][1][-1] -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as call expression. // CASE DESCRIPTION: 'When' with condition as call expression.
fun case_14(value: Any, value1: _Class, value2: _Class?, value3: Int) { fun case_14(value_1: Any, value_2: _Class, value_3: _Class?, value_4: Int) {
fun __fun_1(): () -> Unit { return fun() { } } fun __fun_1(): () -> Unit { return fun() { } }
when (value) { when (value_1) {
_funWithoutArgs(), __fun_1()(), value1.fun_2(value3) -> {} _funWithoutArgs(), __fun_1()(), value_2.fun_2(value_4) -> {}
value2?.fun_2(value3), value2!!.fun_2(value3) -> {} value_3?.fun_2(value_4), value_3!!.fun_2(value_4) -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as property access expression. // CASE DESCRIPTION: 'When' with condition as property access expression.
fun case_15(value: Int, value1: _Class, value2: _Class?) { fun case_15(value_1: Int, value_2: _Class, value_3: _Class?) {
when (value) { when (value_1) {
value1.prop_1, value2?.prop_2 -> {} value_2.prop_1, value_3?.prop_2 -> {}
value1::prop_1.get(), value2!!::prop_3.get() -> {} value_2::prop_1.get(), value_3!!::prop_3.get() -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as fun literal. // CASE DESCRIPTION: 'When' with condition as fun literal.
fun case_16(value: () -> Any): Any { fun case_16(value_1: () -> Any): Any {
val fun_1 = fun() { return } val fun_1 = fun() { return }
return when (value) { return when (value_1) {
fun() {}, fun() { return }, fun(): () -> Unit { return fun() {} }, fun_1 -> {} fun() {}, fun() { return }, fun(): () -> Unit { return fun() {} }, fun_1 -> {}
else -> {} else -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as lambda literal. // CASE DESCRIPTION: 'When' with condition as lambda literal.
fun case_17(value: () -> Any) { fun case_17(value_1: () -> Any) {
val lambda_1 = { 0 } val lambda_1 = { 0 }
when (value) { when (value_1) {
lambda_1, { { {} } }, { -> (Int) lambda_1, { { {} } }, { -> (Int)
{ arg: Int -> { { println(arg) } } } } -> {} { arg: Int -> { { println(arg) } } } } -> {}
} }
} }
// CASE DESCRIPTION: 'When' with condition as object literal. // CASE DESCRIPTION: 'When' with condition as object literal.
fun case_18(value: Any) { fun case_18(value_1: Any) {
val object_1 = object { val object_1 = object {
val prop_1 = 1 val prop_1 = 1
} }
when (value) { when (value_1) {
object {}, object { object {}, object {
private fun fun_1() { } private fun fun_1() { }
val prop_1 = 1 val prop_1 = 1
@@ -181,8 +181,8 @@ class A {
val lambda_1 = { 1 } val lambda_1 = { 1 }
fun fun_1(): Int { return 1 } fun fun_1(): Int { return 1 }
fun case_19(value: Any) { fun case_19(value_1: Any) {
when (value) { when (value_1) {
this, ((this)), this::prop_1.get() -> {} this, ((this)), this::prop_1.get() -> {}
this.prop_1, this.lambda_1() -> {} this.prop_1, this.lambda_1() -> {}
this::lambda_1.get()(), this.fun_1(), this::fun_1.invoke() -> {} this::lambda_1.get()(), this.fun_1(), this::fun_1.invoke() -> {}
@@ -191,32 +191,32 @@ class A {
} }
// CASE DESCRIPTION: 'When' with condition as throw expression. // CASE DESCRIPTION: 'When' with condition as throw expression.
fun case_20(value: Nothing) { fun case_20(value_1: Nothing) {
when (value) { when (value_1) {
<!UNREACHABLE_CODE!>throw Exception(), throw throw throw Exception() -> {}<!> <!UNREACHABLE_CODE!>throw Exception(), throw throw throw Exception() -> {}<!>
} }
} }
// CASE DESCRIPTION: 'When' with condition as return expression. // CASE DESCRIPTION: 'When' with condition as return expression.
fun case_21(value: Nothing) { fun case_21(value_1: Nothing) {
fun r_1() { fun r_1() {
when (value) { when (value_1) {
<!UNREACHABLE_CODE!>return, return return return -> 2<!> <!UNREACHABLE_CODE!>return, return return return -> 2<!>
} }
} }
fun r_2(): List<Int>? { fun r_2(): List<Int>? {
when (value) { when (value_1) {
<!UNREACHABLE_CODE!>return listOf(0, 1, 2), return null -> 2<!> <!UNREACHABLE_CODE!>return listOf(0, 1, 2), return null -> 2<!>
} }
} }
} }
// CASE DESCRIPTION: 'When' with condition as continue expression. // CASE DESCRIPTION: 'When' with condition as continue expression.
fun case_22(value: Nothing) { fun case_22(value_1: Nothing) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
when (value) { when (value_1) {
<!UNREACHABLE_CODE!>continue@loop1, continue@loop2 -> 2<!> <!UNREACHABLE_CODE!>continue@loop1, continue@loop2 -> 2<!>
} }
} }
@@ -224,10 +224,10 @@ fun case_22(value: Nothing) {
} }
// CASE DESCRIPTION: 'When' with condition as break expression. // CASE DESCRIPTION: 'When' with condition as break expression.
fun case_23(value: Nothing) { fun case_23(value_1: Nothing) {
loop1@ while (true) { loop1@ while (true) {
loop2@ while (true) { loop2@ while (true) {
when (value) { when (value_1) {
<!UNREACHABLE_CODE!>break@loop1, break@loop2 -> 2<!> <!UNREACHABLE_CODE!>break@loop1, break@loop2 -> 2<!>
} }
} }
@@ -235,7 +235,7 @@ fun case_23(value: Nothing) {
} }
// CASE DESCRIPTION: 'When' with condition as mixed Nothing expressions. // CASE DESCRIPTION: 'When' with condition as mixed Nothing expressions.
fun case_24(value: Nothing?) = when (<!DEBUG_INFO_CONSTANT!>value<!>) { fun case_24(value_1: Nothing?) = when (<!DEBUG_INFO_CONSTANT!>value_1<!>) {
throw Exception()<!UNREACHABLE_CODE!><!>, <!UNREACHABLE_CODE!>return ""<!> -> <!UNREACHABLE_CODE!>""<!> throw Exception()<!UNREACHABLE_CODE!><!>, <!UNREACHABLE_CODE!>return ""<!> -> <!UNREACHABLE_CODE!>""<!>
<!UNREACHABLE_CODE!>null, return return return "", throw throw throw Exception() -> ""<!> <!UNREACHABLE_CODE!>null, return return return "", throw throw throw Exception() -> ""<!>
<!UNREACHABLE_CODE!>else -> ""<!> <!UNREACHABLE_CODE!>else -> ""<!>
@@ -246,7 +246,7 @@ fun case_24(value: Nothing?) = when (<!DEBUG_INFO_CONSTANT!>value<!>) {
DISCUSSION DISCUSSION
ISSUES: KT-25948 ISSUES: KT-25948
*/ */
fun case_25(value: Boolean) = when (value) { fun case_25(value_1: Boolean) = when (value_1) {
true -> {} true -> {}
throw Exception()<!UNREACHABLE_CODE!><!>, <!UNREACHABLE_CODE!>return<!> -> <!UNREACHABLE_CODE!>{}<!> throw Exception()<!UNREACHABLE_CODE!><!>, <!UNREACHABLE_CODE!>return<!> -> <!UNREACHABLE_CODE!>{}<!>
<!UNREACHABLE_CODE!>false, return return return, throw throw throw Exception() -> {}<!> <!UNREACHABLE_CODE!>false, return return return, throw throw throw Exception() -> {}<!>
@@ -257,9 +257,9 @@ fun case_25(value: Boolean) = when (value) {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-26045 ISSUES: KT-26045
*/ */
fun case_26(value: Int?, value1: _Class, value2: _Class?) { fun case_26(value_1: Int?, value_2: _Class, value_3: _Class?) {
when (value) { when (value_1) {
value1.prop_1, <!DUPLICATE_LABEL_IN_WHEN!>value2?.prop_1<!> -> {} value_2.prop_1, <!DUPLICATE_LABEL_IN_WHEN!>value_3?.prop_1<!> -> {}
10 -> {} 10 -> {}
} }
} }
@@ -1,7 +1,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 7 PARAGRAPH: 7
SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression. SENTENCE: [7] The else condition, which works the exact same way as it would in the form without bound expression.
NUMBER: 1 NUMBER: 1
@@ -9,7 +9,7 @@
*/ */
// CASE DESCRIPTION: Simple when with bound value, with 'else' branch and expression as when condition. // CASE DESCRIPTION: Simple when with bound value, with 'else' branch and expression as when condition.
fun case_1(value: Int?) = when (value) { fun case_1(value_1: Int?) = when (value_1) {
0 -> "" 0 -> ""
1 -> "" 1 -> ""
2 -> "" 2 -> ""
@@ -17,7 +17,7 @@ fun case_1(value: Int?) = when (value) {
} }
// CASE DESCRIPTION: Simple when with bound value, with 'else' branch and type test as when condition. // CASE DESCRIPTION: Simple when with bound value, with 'else' branch and type test as when condition.
fun case_2(value: Any) = when (value) { fun case_2(value_1: Any) = when (value_1) {
is Int -> "" is Int -> ""
is Boolean -> "" is Boolean -> ""
is String -> "" is String -> ""
@@ -25,7 +25,7 @@ fun case_2(value: Any) = when (value) {
} }
// CASE DESCRIPTION: Simple when with bound value, with 'else' branch and range test as when condition. // CASE DESCRIPTION: Simple when with bound value, with 'else' branch and range test as when condition.
fun case_2(value: Int) = when (value) { fun case_2(value_1: Int) = when (value_1) {
in -10..10 -> "" in -10..10 -> ""
in 11..1000 -> "" in 11..1000 -> ""
in 1000..Int.MAX_VALUE -> "" in 1000..Int.MAX_VALUE -> ""
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 9 PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 1 NUMBER: 1
@@ -12,11 +12,11 @@
*/ */
// CASE DESCRIPTION: Checking all types except the correct one (custom types) in 'when' without bound value. // CASE DESCRIPTION: Checking all types except the correct one (custom types) in 'when' without bound value.
fun case_1(value: Int): String { fun case_1(value_1: Int): String {
val whenValue = when { val whenValue = when {
value == 0 -> _ClassLevel2() value_1 == 0 -> _ClassLevel2()
value > 0 && value <= 10 -> _ClassLevel3() value_1 > 0 && value_1 <= 10 -> _ClassLevel3()
value > 10 && value <= 100 -> _ClassLevel4() value_1 > 10 && value_1 <= 100 -> _ClassLevel4()
else -> _ClassLevel5() else -> _ClassLevel5()
} }
@@ -32,8 +32,8 @@ fun case_1(value: Int): String {
} }
// CASE DESCRIPTION: Checking all types except the correct one (custom types) in 'when' with bound value. // CASE DESCRIPTION: Checking all types except the correct one (custom types) in 'when' with bound value.
fun case_2(value: Int): String { fun case_2(value_1: Int): String {
val whenValue = when (value) { val whenValue = when (value_1) {
0 -> _ClassLevel2() 0 -> _ClassLevel2()
1 -> _ClassLevel3() 1 -> _ClassLevel3()
2 -> _ClassLevel4() 2 -> _ClassLevel4()
@@ -55,14 +55,14 @@ fun case_2(value: Int): String {
CASE DESCRIPTION: Checking all types except the correct one (numbers) in 'when' without bound value. CASE DESCRIPTION: Checking all types except the correct one (numbers) in 'when' without bound value.
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-25268 ISSUES: KT-25268
*/ */
fun case_3(value: Int): String { fun case_3(value_1: Int): String {
val whenValue = when { val whenValue = when {
value == 0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!> value_1 == 0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!>
value == 1 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1L<!> value_1 == 1 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1L<!>
value == 2 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.122<!> value_1 == 2 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.122<!>
value == 3 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.000f<!> value_1 == 3 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.000f<!>
value == 4 -> <!IMPLICIT_CAST_TO_ANY!>1 + 10.toShort()<!> value_1 == 4 -> <!IMPLICIT_CAST_TO_ANY!>1 + 10.toShort()<!>
else -> <!IMPLICIT_CAST_TO_ANY!>1 + 10.toByte()<!> else -> <!IMPLICIT_CAST_TO_ANY!>1 + 10.toByte()<!>
} }
@@ -89,8 +89,8 @@ fun case_3(value: Int): String {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-25268 ISSUES: KT-25268
*/ */
fun case_4(value: Int): String { fun case_4(value_1: Int): String {
val whenValue = when (value) { val whenValue = when (value_1) {
0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!> 0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!>
1 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1L<!> 1 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1L<!>
2 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.122<!> 2 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.122<!>
@@ -118,11 +118,11 @@ fun case_4(value: Int): String {
} }
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' without bound value. // CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' without bound value.
fun case_5(value: Int): String { fun case_5(value_1: Int): String {
val whenValue = when { val whenValue = when {
value == 0 -> <!IMPLICIT_CAST_TO_ANY!>10<!> value_1 == 0 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
value > 0 && value <= 10 -> <!IMPLICIT_CAST_TO_ANY!>""<!> value_1 > 0 && value_1 <= 10 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
value > 10 && value <= 100 -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>} value_1 > 10 && value_1 <= 100 -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>}
else -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} else -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
} }
@@ -137,8 +137,8 @@ fun case_5(value: Int): String {
} }
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with bound value. // CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with bound value.
fun case_6(value: Int): String { fun case_6(value_1: Int): String {
val whenValue = when (value) { val whenValue = when (value_1) {
0 -> <!IMPLICIT_CAST_TO_ANY!>10<!> 0 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
1 -> <!IMPLICIT_CAST_TO_ANY!>""<!> 1 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
2 -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>} 2 -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>}
@@ -5,7 +5,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 9 PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 2 NUMBER: 2
@@ -13,8 +13,8 @@
*/ */
// CASE DESCRIPTION: Checking all types except the correct one in 'when'. // CASE DESCRIPTION: Checking all types except the correct one in 'when'.
fun case_1(value: _EnumClass): String { fun case_1(value_1: _EnumClass): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_EnumClass.EAST -> _ClassLevel2() _EnumClass.EAST -> _ClassLevel2()
_EnumClass.NORTH -> _ClassLevel3() _EnumClass.NORTH -> _ClassLevel3()
_EnumClass.SOUTH -> _ClassLevel4() _EnumClass.SOUTH -> _ClassLevel4()
@@ -33,8 +33,8 @@ fun case_1(value: _EnumClass): String {
} }
// CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch. // CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch.
fun case_2(value: _EnumClass?): String { fun case_2(value_1: _EnumClass?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_EnumClass.EAST -> _ClassLevel2() _EnumClass.EAST -> _ClassLevel2()
_EnumClass.NORTH -> _ClassLevel3() _EnumClass.NORTH -> _ClassLevel3()
_EnumClass.SOUTH -> _ClassLevel4() _EnumClass.SOUTH -> _ClassLevel4()
@@ -56,8 +56,8 @@ fun case_2(value: _EnumClass?): String {
} }
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'. // CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'.
fun case_3(value: _EnumClass): String { fun case_3(value_1: _EnumClass): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!> _EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!>
_EnumClass.NORTH -> <!IMPLICIT_CAST_TO_ANY!>""<!> _EnumClass.NORTH -> <!IMPLICIT_CAST_TO_ANY!>""<!>
_EnumClass.SOUTH -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>} _EnumClass.SOUTH -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>}
@@ -75,8 +75,8 @@ fun case_3(value: _EnumClass): String {
} }
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch. // CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch.
fun case_4(value: _EnumClass?): String { fun case_4(value_1: _EnumClass?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!> _EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!>
_EnumClass.NORTH -> <!IMPLICIT_CAST_TO_ANY!>""<!> _EnumClass.NORTH -> <!IMPLICIT_CAST_TO_ANY!>""<!>
_EnumClass.SOUTH -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>} _EnumClass.SOUTH -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>}
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 9 PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 3 NUMBER: 3
@@ -12,8 +12,8 @@
*/ */
// CASE DESCRIPTION: Checking all types except the correct one in 'when'. // CASE DESCRIPTION: Checking all types except the correct one in 'when'.
fun case_1(value: Boolean): String { fun case_1(value_1: Boolean): String {
val whenValue = when (value) { val whenValue = when (value_1) {
true -> _ClassLevel2() true -> _ClassLevel2()
false -> _ClassLevel3() false -> _ClassLevel3()
} }
@@ -28,8 +28,8 @@ fun case_1(value: Boolean): String {
} }
// CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch. // CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch.
fun case_2(value: Boolean?): String { fun case_2(value_1: Boolean?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
true -> _ClassLevel2() true -> _ClassLevel2()
false -> _ClassLevel3() false -> _ClassLevel3()
null -> _ClassLevel4() null -> _ClassLevel4()
@@ -45,8 +45,8 @@ fun case_2(value: Boolean?): String {
} }
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'. // CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'.
fun case_3(value: Boolean): String { fun case_3(value_1: Boolean): String {
val whenValue = when (value) { val whenValue = when (value_1) {
true -> <!IMPLICIT_CAST_TO_ANY!>10<!> true -> <!IMPLICIT_CAST_TO_ANY!>10<!>
false -> <!IMPLICIT_CAST_TO_ANY!>""<!> false -> <!IMPLICIT_CAST_TO_ANY!>""<!>
} }
@@ -60,8 +60,8 @@ fun case_3(value: Boolean): String {
} }
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch. // CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch.
fun case_4(value: Boolean?): String { fun case_4(value_1: Boolean?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
true -> <!IMPLICIT_CAST_TO_ANY!>10<!> true -> <!IMPLICIT_CAST_TO_ANY!>10<!>
false -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>} false -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>}
null -> <!IMPLICIT_CAST_TO_ANY!>""<!> null -> <!IMPLICIT_CAST_TO_ANY!>""<!>
@@ -5,7 +5,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 9 PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 4 NUMBER: 4
@@ -13,8 +13,8 @@
*/ */
// CASE DESCRIPTION: Checking all types except the correct one in 'when'. // CASE DESCRIPTION: Checking all types except the correct one in 'when'.
fun case_1(value: _SealedClass): String { fun case_1(value_1: _SealedClass): String {
val whenValue = when (value) { val whenValue = when (value_1) {
is _SealedChild1 -> _ClassLevel2() is _SealedChild1 -> _ClassLevel2()
is _SealedChild2 -> _ClassLevel3() is _SealedChild2 -> _ClassLevel3()
is _SealedChild3 -> _ClassLevel4() is _SealedChild3 -> _ClassLevel4()
@@ -30,8 +30,8 @@ fun case_1(value: _SealedClass): String {
} }
// CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch. // CASE DESCRIPTION: Checking all types except the correct one in 'when' with null-check branch.
fun case_2(value: _SealedClass?): String { fun case_2(value_1: _SealedClass?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
is _SealedChild1 -> _ClassLevel2() is _SealedChild1 -> _ClassLevel2()
is _SealedChild2 -> _ClassLevel3() is _SealedChild2 -> _ClassLevel3()
is _SealedChild3 -> _ClassLevel4() is _SealedChild3 -> _ClassLevel4()
@@ -50,8 +50,8 @@ fun case_2(value: _SealedClass?): String {
} }
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'. // CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when'.
fun case_3(value: _SealedClass): String { fun case_3(value_1: _SealedClass): String {
val whenValue = when (value) { val whenValue = when (value_1) {
is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!> is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
is _SealedChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!> is _SealedChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
is _SealedChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} is _SealedChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
@@ -66,8 +66,8 @@ fun case_3(value: _SealedClass): String {
} }
// CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch. // CASE DESCRIPTION: Checking all types except the Any (implicit cast to any) in 'when' with null-check branch.
fun case_4(value: _SealedClass?): String { fun case_4(value_1: _SealedClass?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!> is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
is _SealedChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!> is _SealedChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
is _SealedChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} is _SealedChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
@@ -85,8 +85,8 @@ fun case_4(value: _SealedClass?): String {
} }
// CASE DESCRIPTION: Checking objects except the correct one in 'when'. // CASE DESCRIPTION: Checking objects except the correct one in 'when'.
fun case_5(value: _SealedClassWithObjects): String { fun case_5(value_1: _SealedClassWithObjects): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> _ClassLevel2() _SealedWithObjectsChild1 -> _ClassLevel2()
_SealedWithObjectsChild2 -> _ClassLevel3() _SealedWithObjectsChild2 -> _ClassLevel3()
_SealedWithObjectsChild3 -> _ClassLevel4() _SealedWithObjectsChild3 -> _ClassLevel4()
@@ -102,8 +102,8 @@ fun case_5(value: _SealedClassWithObjects): String {
} }
// CASE DESCRIPTION: Checking objects except the correct one in 'when' with null-check branch. // CASE DESCRIPTION: Checking objects except the correct one in 'when' with null-check branch.
fun case_6(value: _SealedClassWithObjects?): String { fun case_6(value_1: _SealedClassWithObjects?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> _ClassLevel2() _SealedWithObjectsChild1 -> _ClassLevel2()
_SealedWithObjectsChild2 -> _ClassLevel3() _SealedWithObjectsChild2 -> _ClassLevel3()
_SealedWithObjectsChild3 -> _ClassLevel4() _SealedWithObjectsChild3 -> _ClassLevel4()
@@ -122,8 +122,8 @@ fun case_6(value: _SealedClassWithObjects?): String {
} }
// CASE DESCRIPTION: Checking objects except the Any (implicit cast to any) in 'when'. // CASE DESCRIPTION: Checking objects except the Any (implicit cast to any) in 'when'.
fun case_7(value: _SealedClassWithObjects): String { fun case_7(value_1: _SealedClassWithObjects): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!> _SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
_SealedWithObjectsChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!> _SealedWithObjectsChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
_SealedWithObjectsChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} _SealedWithObjectsChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
@@ -138,8 +138,8 @@ fun case_7(value: _SealedClassWithObjects): String {
} }
// CASE DESCRIPTION: Checking objects except the Any (implicit cast to any) in 'when' with null-check branch. // CASE DESCRIPTION: Checking objects except the Any (implicit cast to any) in 'when' with null-check branch.
fun case_8(value: _SealedClassWithObjects?): String { fun case_8(value_1: _SealedClassWithObjects?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!> _SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
_SealedWithObjectsChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!> _SealedWithObjectsChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
_SealedWithObjectsChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} _SealedWithObjectsChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
@@ -157,8 +157,8 @@ fun case_8(value: _SealedClassWithObjects?): String {
} }
// CASE DESCRIPTION: Checking all types except the correct one in 'when' with 'else' branch. // CASE DESCRIPTION: Checking all types except the correct one in 'when' with 'else' branch.
fun case_9(value: _SealedClassWithObjects?): String { fun case_9(value_1: _SealedClassWithObjects?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
is _SealedClassWithObjects -> _ClassLevel2() is _SealedClassWithObjects -> _ClassLevel2()
else -> _ClassLevel3() else -> _ClassLevel3()
} }
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 9 PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 1 NUMBER: 1
@@ -12,11 +12,11 @@
*/ */
// CASE DESCRIPTION: Checking correctness type (custom types) in 'when' without bound value. // CASE DESCRIPTION: Checking correctness type (custom types) in 'when' without bound value.
fun case_1(value: Int): String { fun case_1(value_1: Int): String {
val whenValue = when { val whenValue = when {
value == 0 -> _ClassLevel2() value_1 == 0 -> _ClassLevel2()
value > 0 && value <= 10 -> _ClassLevel3() value_1 > 0 && value_1 <= 10 -> _ClassLevel3()
value > 10 && value <= 100 -> _ClassLevel4() value_1 > 10 && value_1 <= 100 -> _ClassLevel4()
else -> _ClassLevel5() else -> _ClassLevel5()
} }
@@ -27,8 +27,8 @@ fun case_1(value: Int): String {
} }
// CASE DESCRIPTION: Checking correctness type (custom types) in 'when' with bound value. // CASE DESCRIPTION: Checking correctness type (custom types) in 'when' with bound value.
fun case_2(value: Int): String { fun case_2(value_1: Int): String {
val whenValue = when (value) { val whenValue = when (value_1) {
0 -> _ClassLevel2() 0 -> _ClassLevel2()
1 -> _ClassLevel3() 1 -> _ClassLevel3()
2 -> _ClassLevel4() 2 -> _ClassLevel4()
@@ -46,13 +46,13 @@ fun case_2(value: Int): String {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-25268 ISSUES: KT-25268
*/ */
fun case_3(value: Int): String { fun case_3(value_1: Int): String {
val whenValue = when { val whenValue = when {
value == 0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!> value_1 == 0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!>
value == 1 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1L<!> value_1 == 1 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1L<!>
value == 2 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.122<!> value_1 == 2 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.122<!>
value == 3 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.000f<!> value_1 == 3 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.000f<!>
value == 4 -> <!IMPLICIT_CAST_TO_ANY!>1 + 10.toShort()<!> value_1 == 4 -> <!IMPLICIT_CAST_TO_ANY!>1 + 10.toShort()<!>
else -> <!IMPLICIT_CAST_TO_ANY!>1 + 10.toShort()<!> else -> <!IMPLICIT_CAST_TO_ANY!>1 + 10.toShort()<!>
} }
@@ -66,8 +66,8 @@ fun case_3(value: Int): String {
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
ISSUES: KT-25268 ISSUES: KT-25268
*/ */
fun case_4(value: Int): String { fun case_4(value_1: Int): String {
val whenValue = when (value) { val whenValue = when (value_1) {
0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!> 0 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1<!>
1 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1L<!> 1 -> <!IMPLICIT_CAST_TO_ANY!>1 + 1L<!>
2 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.122<!> 2 -> <!IMPLICIT_CAST_TO_ANY!>1 + -.122<!>
@@ -82,11 +82,11 @@ fun case_4(value: Int): String {
} }
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' without bound value. // CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' without bound value.
fun case_5(value: Int): String { fun case_5(value_1: Int): String {
val whenValue = when { val whenValue = when {
value == 0 -> <!IMPLICIT_CAST_TO_ANY!>10<!> value_1 == 0 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
value > 0 && value <= 10 -> <!IMPLICIT_CAST_TO_ANY!>""<!> value_1 > 0 && value_1 <= 10 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
value > 10 && value <= 100 -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>} value_1 > 10 && value_1 <= 100 -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>}
else -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} else -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
} }
@@ -97,8 +97,8 @@ fun case_5(value: Int): String {
} }
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with bound value. // CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with bound value.
fun case_6(value: Int): String { fun case_6(value_1: Int): String {
val whenValue = when (value) { val whenValue = when (value_1) {
0 -> <!IMPLICIT_CAST_TO_ANY!>10<!> 0 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
1 -> <!IMPLICIT_CAST_TO_ANY!>""<!> 1 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
2 -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>} 2 -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>}
@@ -5,7 +5,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 9 PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 2 NUMBER: 2
@@ -13,8 +13,8 @@
*/ */
// CASE DESCRIPTION: Checking correct type in 'when'. // CASE DESCRIPTION: Checking correct type in 'when'.
fun case_1(value: _EnumClass): String { fun case_1(value_1: _EnumClass): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_EnumClass.EAST -> _ClassLevel2() _EnumClass.EAST -> _ClassLevel2()
_EnumClass.NORTH -> _ClassLevel3() _EnumClass.NORTH -> _ClassLevel3()
_EnumClass.SOUTH -> _ClassLevel4() _EnumClass.SOUTH -> _ClassLevel4()
@@ -28,8 +28,8 @@ fun case_1(value: _EnumClass): String {
} }
// CASE DESCRIPTION: Checking correct type in 'when' with null-check branch. // CASE DESCRIPTION: Checking correct type in 'when' with null-check branch.
fun case_2(value: _EnumClass?): String { fun case_2(value_1: _EnumClass?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_EnumClass.EAST -> _ClassLevel2() _EnumClass.EAST -> _ClassLevel2()
_EnumClass.NORTH -> _ClassLevel3() _EnumClass.NORTH -> _ClassLevel3()
_EnumClass.SOUTH -> _ClassLevel4() _EnumClass.SOUTH -> _ClassLevel4()
@@ -44,8 +44,8 @@ fun case_2(value: _EnumClass?): String {
} }
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'. // CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'.
fun case_3(value: _EnumClass): String { fun case_3(value_1: _EnumClass): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!> _EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!>
_EnumClass.NORTH -> <!IMPLICIT_CAST_TO_ANY!>""<!> _EnumClass.NORTH -> <!IMPLICIT_CAST_TO_ANY!>""<!>
_EnumClass.SOUTH -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>} _EnumClass.SOUTH -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>}
@@ -59,8 +59,8 @@ fun case_3(value: _EnumClass): String {
} }
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch. // CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch.
fun case_4(value: _EnumClass?): String { fun case_4(value_1: _EnumClass?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!> _EnumClass.EAST -> <!IMPLICIT_CAST_TO_ANY!>10<!>
_EnumClass.NORTH -> <!IMPLICIT_CAST_TO_ANY!>""<!> _EnumClass.NORTH -> <!IMPLICIT_CAST_TO_ANY!>""<!>
_EnumClass.SOUTH -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>} _EnumClass.SOUTH -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>}
@@ -4,7 +4,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 9 PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 3 NUMBER: 3
@@ -12,8 +12,8 @@
*/ */
// CASE DESCRIPTION: Checking correct type in 'when'. // CASE DESCRIPTION: Checking correct type in 'when'.
fun case_1(value: Boolean): String { fun case_1(value_1: Boolean): String {
val whenValue = when (value) { val whenValue = when (value_1) {
true -> _ClassLevel2() true -> _ClassLevel2()
false -> _ClassLevel3() false -> _ClassLevel3()
} }
@@ -25,8 +25,8 @@ fun case_1(value: Boolean): String {
} }
// CASE DESCRIPTION: Checking correct type in 'when' with null-check branch. // CASE DESCRIPTION: Checking correct type in 'when' with null-check branch.
fun case_2(value: Boolean?): String { fun case_2(value_1: Boolean?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
true -> _ClassLevel2() true -> _ClassLevel2()
false -> _ClassLevel3() false -> _ClassLevel3()
null -> _ClassLevel4() null -> _ClassLevel4()
@@ -40,8 +40,8 @@ fun case_2(value: Boolean?): String {
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'. // CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'.
fun case_3(value: Boolean): String { fun case_3(value_1: Boolean): String {
val whenValue = when (value) { val whenValue = when (value_1) {
true -> <!IMPLICIT_CAST_TO_ANY!>10<!> true -> <!IMPLICIT_CAST_TO_ANY!>10<!>
false -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} false -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
} }
@@ -54,8 +54,8 @@ fun case_3(value: Boolean): String {
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch. // CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch.
fun case_4(value: Boolean?): String { fun case_4(value_1: Boolean?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
true -> <!IMPLICIT_CAST_TO_ANY!>10<!> true -> <!IMPLICIT_CAST_TO_ANY!>10<!>
false -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>} false -> {<!IMPLICIT_CAST_TO_ANY!>{}<!>}
null -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} null -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
@@ -5,7 +5,7 @@
/* /*
KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
SECTION: when-expression SECTIONS: when-expression
PARAGRAPH: 9 PARAGRAPH: 9
SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries. SENTENCE: [1] The type of the resulting expression is the least upper bound of the types of all the entries.
NUMBER: 4 NUMBER: 4
@@ -13,8 +13,8 @@
*/ */
// CASE DESCRIPTION: Checking correct type in 'when'. // CASE DESCRIPTION: Checking correct type in 'when'.
fun case_1(value: _SealedClass): String { fun case_1(value_1: _SealedClass): String {
val whenValue = when (value) { val whenValue = when (value_1) {
is _SealedChild1 -> _ClassLevel2() is _SealedChild1 -> _ClassLevel2()
is _SealedChild2 -> _ClassLevel3() is _SealedChild2 -> _ClassLevel3()
is _SealedChild3 -> _ClassLevel4() is _SealedChild3 -> _ClassLevel4()
@@ -27,8 +27,8 @@ fun case_1(value: _SealedClass): String {
} }
// CASE DESCRIPTION: Checking correct type in 'when' with null-check branch. // CASE DESCRIPTION: Checking correct type in 'when' with null-check branch.
fun case_2(value: _SealedClass?): String { fun case_2(value_1: _SealedClass?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
is _SealedChild1 -> _ClassLevel2() is _SealedChild1 -> _ClassLevel2()
is _SealedChild2 -> _ClassLevel3() is _SealedChild2 -> _ClassLevel3()
is _SealedChild3 -> _ClassLevel4() is _SealedChild3 -> _ClassLevel4()
@@ -42,8 +42,8 @@ fun case_2(value: _SealedClass?): String {
} }
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'. // CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when'.
fun case_3(value: _SealedClass): String { fun case_3(value_1: _SealedClass): String {
val whenValue = when (value) { val whenValue = when (value_1) {
is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!> is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
is _SealedChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!> is _SealedChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
is _SealedChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} is _SealedChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
@@ -56,8 +56,8 @@ fun case_3(value: _SealedClass): String {
} }
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch. // CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch.
fun case_4(value: _SealedClass?): String { fun case_4(value_1: _SealedClass?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!> is _SealedChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
is _SealedChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!> is _SealedChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
is _SealedChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} is _SealedChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
@@ -71,8 +71,8 @@ fun case_4(value: _SealedClass?): String {
} }
// CASE DESCRIPTION: Checking correct type in 'when' (equality with objects). // CASE DESCRIPTION: Checking correct type in 'when' (equality with objects).
fun case_5(value: _SealedClassWithObjects): String { fun case_5(value_1: _SealedClassWithObjects): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> _ClassLevel2() _SealedWithObjectsChild1 -> _ClassLevel2()
_SealedWithObjectsChild2 -> _ClassLevel3() _SealedWithObjectsChild2 -> _ClassLevel3()
_SealedWithObjectsChild3 -> _ClassLevel4() _SealedWithObjectsChild3 -> _ClassLevel4()
@@ -85,8 +85,8 @@ fun case_5(value: _SealedClassWithObjects): String {
} }
// CASE DESCRIPTION: Checking correct type in 'when' (equality with objects) with null-check branch. // CASE DESCRIPTION: Checking correct type in 'when' (equality with objects) with null-check branch.
fun case_6(value: _SealedClassWithObjects?): String { fun case_6(value_1: _SealedClassWithObjects?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> _ClassLevel2() _SealedWithObjectsChild1 -> _ClassLevel2()
_SealedWithObjectsChild2 -> _ClassLevel3() _SealedWithObjectsChild2 -> _ClassLevel3()
_SealedWithObjectsChild3 -> _ClassLevel4() _SealedWithObjectsChild3 -> _ClassLevel4()
@@ -100,8 +100,8 @@ fun case_6(value: _SealedClassWithObjects?): String {
} }
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' (equality with objects). // CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' (equality with objects).
fun case_7(value: _SealedClassWithObjects): String { fun case_7(value_1: _SealedClassWithObjects): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!> _SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
_SealedWithObjectsChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!> _SealedWithObjectsChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
_SealedWithObjectsChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} _SealedWithObjectsChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
@@ -114,8 +114,8 @@ fun case_7(value: _SealedClassWithObjects): String {
} }
// CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch (equality with objects). // CASE DESCRIPTION: Checking Any type (implicit cast to any) in 'when' with null-check branch (equality with objects).
fun case_8(value: _SealedClassWithObjects?): String { fun case_8(value_1: _SealedClassWithObjects?): String {
val whenValue = when (value) { val whenValue = when (value_1) {
_SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!> _SealedWithObjectsChild1 -> <!IMPLICIT_CAST_TO_ANY!>10<!>
_SealedWithObjectsChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!> _SealedWithObjectsChild2 -> <!IMPLICIT_CAST_TO_ANY!>""<!>
_SealedWithObjectsChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {} _SealedWithObjectsChild3 -> <!IMPLICIT_CAST_TO_ANY!>object<!> {}
@@ -129,8 +129,8 @@ fun case_8(value: _SealedClassWithObjects?): String {
} }
// CASE DESCRIPTION: Checking correct basic type (Int) in 'when' with. // CASE DESCRIPTION: Checking correct basic type (Int) in 'when' with.
fun case_9(value: _SealedClassWithObjects): String { fun case_9(value_1: _SealedClassWithObjects): String {
val whenValue = when (value) { val whenValue = when (value_1) {
<!USELESS_IS_CHECK!>is _SealedClassWithObjects<!> -> 10 <!USELESS_IS_CHECK!>is _SealedClassWithObjects<!> -> 10
} }
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, common CATEGORIES: analysis, common
NUMBER: 1 NUMBER: 1
DESCRIPTION: Analysis by contracts with mixed CallsInPlace and Returns effects. DESCRIPTION: Analysis by contracts with mixed CallsInPlace and Returns effects.
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, common CATEGORIES: analysis, common
NUMBER: 1 NUMBER: 1
DESCRIPTION: Analysis by contracts with mixed CallsInPlace and Returns effects. DESCRIPTION: Analysis by contracts with mixed CallsInPlace and Returns effects.
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, common CATEGORIES: analysis, common
NUMBER: 2 NUMBER: 2
DESCRIPTION: Recursion in the lambda of contract function. DESCRIPTION: Recursion in the lambda of contract function.
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 1 NUMBER: 1
DESCRIPTION: val/var reassignment and/or uninitialized variable usages based on CallsInPlace effect with wrong invocation kind DESCRIPTION: val/var reassignment and/or uninitialized variable usages based on CallsInPlace effect with wrong invocation kind
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 2 NUMBER: 2
DESCRIPTION: val/var reassignment and/or uninitialized variable usages based on nested CallsInPlace effects with wrong invocation kind DESCRIPTION: val/var reassignment and/or uninitialized variable usages based on nested CallsInPlace effects with wrong invocation kind
*/ */
@@ -8,7 +8,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 3 NUMBER: 3
DESCRIPTION: val/var reassignment and/or uninitialized variable usages with compelx control flow inside/outside lambda of contract function with CallsInPlace effect DESCRIPTION: val/var reassignment and/or uninitialized variable usages with compelx control flow inside/outside lambda of contract function with CallsInPlace effect
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 4 NUMBER: 4
DESCRIPTION: CallsInPlace contract functions with name shadowing and wrong invocation kind DESCRIPTION: CallsInPlace contract functions with name shadowing and wrong invocation kind
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 5 NUMBER: 5
DESCRIPTION: CallsInPlace contract functions with invalid lambda passing to function parameter. DESCRIPTION: CallsInPlace contract functions with invalid lambda passing to function parameter.
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 6 NUMBER: 6
DESCRIPTION: Check the lack of CallsInPlace effect on the lambda in the parentheses. DESCRIPTION: Check the lack of CallsInPlace effect on the lambda in the parentheses.
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 1 NUMBER: 1
DESCRIPTION: val/var assignments using contract functions with CallsInPlace effect DESCRIPTION: val/var assignments using contract functions with CallsInPlace effect
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 2 NUMBER: 2
DESCRIPTION: Nested val/var assignments using contract functions with CallsInPlace effect DESCRIPTION: Nested val/var assignments using contract functions with CallsInPlace effect
*/ */
@@ -8,7 +8,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 3 NUMBER: 3
DESCRIPTION: val/var assignments or subsequent usages with compelx control flow inside/outside lambda of contract function with CallsInPlace effect DESCRIPTION: val/var assignments or subsequent usages with compelx control flow inside/outside lambda of contract function with CallsInPlace effect
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 4 NUMBER: 4
DESCRIPTION: CallsInPlace contract functions with name shadowing DESCRIPTION: CallsInPlace contract functions with name shadowing
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, initialization CATEGORIES: analysis, controlFlow, initialization
NUMBER: 5 NUMBER: 5
DESCRIPTION: Smart initialization with correspond contract function with default value before lambda. DESCRIPTION: Smart initialization with correspond contract function with default value before lambda.
ISSUES: KT-26444 ISSUES: KT-26444
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, unreachableCode CATEGORIES: analysis, controlFlow, unreachableCode
NUMBER: 1 NUMBER: 1
DESCRIPTION: Using not allowed break and continue inside lambda of contract function DESCRIPTION: Using not allowed break and continue inside lambda of contract function
*/ */
@@ -8,7 +8,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, unreachableCode CATEGORIES: analysis, controlFlow, unreachableCode
NUMBER: 1 NUMBER: 1
DESCRIPTION: Unreachable code detection using contract function with CallsInPlace effect DESCRIPTION: Unreachable code detection using contract function with CallsInPlace effect
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, unreachableCode CATEGORIES: analysis, controlFlow, unreachableCode
NUMBER: 2 NUMBER: 2
DESCRIPTION: Check for lack of unreachable code report when 'at most once' and 'unknown' invokations in CallsInPlace effect used. DESCRIPTION: Check for lack of unreachable code report when 'at most once' and 'unknown' invokations in CallsInPlace effect used.
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, unreachableCode CATEGORIES: analysis, controlFlow, unreachableCode
NUMBER: 3 NUMBER: 3
DESCRIPTION: Unreachable code detection using local functions or labdas combined with contract functions with CallsInPlace effect DESCRIPTION: Unreachable code detection using local functions or labdas combined with contract functions with CallsInPlace effect
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, unreachableCode CATEGORIES: analysis, controlFlow, unreachableCode
NUMBER: 4 NUMBER: 4
DESCRIPTION: Unreachable code detection using nested contract functions with CallsInPlace effect DESCRIPTION: Unreachable code detection using nested contract functions with CallsInPlace effect
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, unreachableCode CATEGORIES: analysis, controlFlow, unreachableCode
NUMBER: 5 NUMBER: 5
DESCRIPTION: Unreachable code detection using contract functions with complex control flow inside DESCRIPTION: Unreachable code detection using contract functions with complex control flow inside
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, unreachableCode CATEGORIES: analysis, controlFlow, unreachableCode
NUMBER: 6 NUMBER: 6
DESCRIPTION: Check for lack of unreachable code report when in complex control flow of contract function lambda not all branches are doing non-local return DESCRIPTION: Check for lack of unreachable code report when in complex control flow of contract function lambda not all branches are doing non-local return
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, controlFlow, unreachableCode CATEGORIES: analysis, controlFlow, unreachableCode
NUMBER: 7 NUMBER: 7
DESCRIPTION: Smart initialization with correspond contract function with default value before lambda. DESCRIPTION: Smart initialization with correspond contract function with default value before lambda.
ISSUES: KT-26444 ISSUES: KT-26444
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 1 NUMBER: 1
DESCRIPTION: Smartcasts using Returns effects with simple type checking, not-null conditions and custom condition (condition for smartcast outside contract). DESCRIPTION: Smartcasts using Returns effects with simple type checking, not-null conditions and custom condition (condition for smartcast outside contract).
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 10 NUMBER: 10
DESCRIPTION: Check the lack of smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'unknown' or 'at most once' CallsInPlace effects. DESCRIPTION: Check the lack of smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'unknown' or 'at most once' CallsInPlace effects.
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 11 NUMBER: 11
DESCRIPTION: Check smartcasts using double negation (returnsFalse/invert type checking/not operator). DESCRIPTION: Check smartcasts using double negation (returnsFalse/invert type checking/not operator).
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 12 NUMBER: 12
DESCRIPTION: Check smartcast to upper bound of the types in disjunction. DESCRIPTION: Check smartcast to upper bound of the types in disjunction.
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 13 NUMBER: 13
DESCRIPTION: Smartcast using many of the various Returns effects on the same values. DESCRIPTION: Smartcast using many of the various Returns effects on the same values.
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 2 NUMBER: 2
DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions outside contract (custom condition). DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions outside contract (custom condition).
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 3 NUMBER: 3
DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions inside contract. DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions inside contract.
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 4 NUMBER: 4
DESCRIPTION: Smartcasts using Returns effects with simple type checking and not-null conditions on receiver inside contract. DESCRIPTION: Smartcasts using Returns effects with simple type checking and not-null conditions on receiver inside contract.
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 5 NUMBER: 5
DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver inside contract. DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver inside contract.
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 6 NUMBER: 6
DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver and some values (mixed) inside contract. DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver and some values (mixed) inside contract.
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 7 NUMBER: 7
DESCRIPTION: Smartcasts using Returns effects with nested or subsequent contract function calls. DESCRIPTION: Smartcasts using Returns effects with nested or subsequent contract function calls.
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 8 NUMBER: 8
DESCRIPTION: Smartcasts using some Returns effects. DESCRIPTION: Smartcasts using some Returns effects.
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 9 NUMBER: 9
DESCRIPTION: Smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'exactly once' or 'at least once' CallsInPlace effects. DESCRIPTION: Smartcasts after non-null assertions or not-null value assignment in lambdas of contract function with 'exactly once' or 'at least once' CallsInPlace effects.
UNEXPECTED BEHAVIOUR UNEXPECTED BEHAVIOUR
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 1 NUMBER: 1
DESCRIPTION: Smartcasts using Returns effects with simple type checking, not-null conditions and custom condition (condition for smartcast outside contract). DESCRIPTION: Smartcasts using Returns effects with simple type checking, not-null conditions and custom condition (condition for smartcast outside contract).
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 10 NUMBER: 10
DESCRIPTION: Smartcasts with correspond contract function with default value in last parameter. DESCRIPTION: Smartcasts with correspond contract function with default value in last parameter.
ISSUES: KT-26444 ISSUES: KT-26444
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 11 NUMBER: 11
DESCRIPTION: Check smartcasts with passing same fields of instances of the same class in contract function with conjunction not-null condition. DESCRIPTION: Check smartcasts with passing same fields of instances of the same class in contract function with conjunction not-null condition.
ISSUES: KT-26300 ISSUES: KT-26300
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 2 NUMBER: 2
DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions outside contract (custom condition). DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions outside contract (custom condition).
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 3 NUMBER: 3
DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions inside contract. DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions inside contract.
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 4 NUMBER: 4
DESCRIPTION: Smartcasts using Returns effects with simple type checking and not-null conditions on receiver inside contract. DESCRIPTION: Smartcasts using Returns effects with simple type checking and not-null conditions on receiver inside contract.
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 5 NUMBER: 5
DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver inside contract. DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver inside contract.
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 6 NUMBER: 6
DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver and some values (mixed) inside contract. DESCRIPTION: Smartcasts using Returns effects with complex (conjunction/disjunction) type checking and not-null conditions on receiver and some values (mixed) inside contract.
*/ */
@@ -6,7 +6,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 7 NUMBER: 7
DESCRIPTION: Smartcasts using Returns effects with nested or subsequent contract function calls. DESCRIPTION: Smartcasts using Returns effects with nested or subsequent contract function calls.
*/ */
@@ -7,7 +7,7 @@
KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE) KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (POSITIVE)
SECTION: contracts SECTION: contracts
CATEGORY: analysis, smartcasts CATEGORIES: analysis, smartcasts
NUMBER: 8 NUMBER: 8
DESCRIPTION: Smartcasts using some Returns effects. DESCRIPTION: Smartcasts using some Returns effects.
*/ */

Some files were not shown because too many files have changed in this diff Show More