[TD] Update diagnostics test data due to new test runners
Update includes:
- Changing syntax of `OI/`NI` tags from `<!NI;TAG!>` to `<!TAG{NI}!>`
- Fix some incorrect directives
- Change order of diagnostics in some places
- Remove ignored diagnostics from FIR test data (previously `DIAGNOSTICS` didn't work)
- Update FIR dumps in some places and add `FIR_IDENTICAL` if needed
- Replace all JAVAC_SKIP with SKIP_JAVAC directive
This commit is contained in:
@@ -1,4 +1,14 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 6
|
||||
*/
|
||||
class A
|
||||
|
||||
fun test(a: Any): String {
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 8
|
||||
*/
|
||||
class A
|
||||
|
||||
fun test(a: Any) {
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 8
|
||||
*/
|
||||
enum class My { A, B }
|
||||
|
||||
fun test(a: My): String {
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 8
|
||||
*/
|
||||
class A
|
||||
|
||||
fun test(a: Any): String {
|
||||
|
||||
+8
-1
@@ -1,3 +1,10 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 2 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
*/
|
||||
fun foo(x: Int, y: Int): Int =
|
||||
when {
|
||||
x > 0, y > 0,<!SYNTAX!>,<!> x < 0 -> 1
|
||||
@@ -8,4 +15,4 @@ fun bar(x: Int): Int =
|
||||
when (x) {
|
||||
0 -> 0
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,4 +15,4 @@ fun bar(x: Int): Int =
|
||||
when (x) {
|
||||
0 -> 0
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 2 -> sentence 4
|
||||
* expressions, when-expression -> paragraph 2 -> sentence 5
|
||||
*/
|
||||
|
||||
package test
|
||||
|
||||
const val four = 4
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
// KT-2902 Check for null should be required when match nullable enum element
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 10
|
||||
*/
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
|
||||
+9
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 10
|
||||
*/
|
||||
|
||||
enum class E { A, B }
|
||||
|
||||
fun foo(e: E, something: Any?): Int {
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, conditional-expressions -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, boolean-operators -> paragraph 0 -> sentence 0
|
||||
* control--and-data-flow-analysis, control-flow-graph, statements-1 -> paragraph 0 -> sentence 0
|
||||
*/
|
||||
|
||||
enum class Color { RED, GREEN, BLUE }
|
||||
|
||||
fun foo(arr: Array<Color>): Color {
|
||||
@@ -11,4 +22,4 @@ fun foo(arr: Array<Color>): Color {
|
||||
return Color.BLUE
|
||||
}
|
||||
return Color.GREEN
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,4 @@ fun foo(arr: Array<Color>): Color {
|
||||
<!UNREACHABLE_CODE!>return Color.BLUE<!>
|
||||
}
|
||||
return Color.GREEN
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
*/
|
||||
|
||||
enum class MyEnum {
|
||||
A, B, C
|
||||
}
|
||||
@@ -8,4 +17,4 @@ fun foo(x: MyEnum): Int {
|
||||
is <!UNRESOLVED_REFERENCE!>MyEnum.B<!> -> 2
|
||||
is <!UNRESOLVED_REFERENCE!>MyEnum.C<!> -> 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,4 @@ fun foo(x: MyEnum): Int {
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>B<!><!> -> 2
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>C<!><!> -> 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 5
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
*/
|
||||
|
||||
enum class MyEnum {
|
||||
A, B, C
|
||||
}
|
||||
@@ -8,4 +18,4 @@ fun foo(x: MyEnum): Int {
|
||||
is <!UNRESOLVED_REFERENCE!>MyEnum.B<!> -> 2
|
||||
is <!UNRESOLVED_REFERENCE!>MyEnum.C<!> -> 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,4 @@ fun foo(x: MyEnum): Int {
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>B<!><!> -> 2
|
||||
is <!IS_ENUM_ENTRY!>MyEnum.<!ENUM_ENTRY_AS_TYPE!>C<!><!> -> 3
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 5
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 3
|
||||
*/
|
||||
|
||||
enum class Direction {
|
||||
NORTH, SOUTH, WEST, EAST
|
||||
}
|
||||
@@ -12,4 +23,4 @@ fun foo(dir: Direction): Int {
|
||||
Direction.EAST -> res = 4
|
||||
}
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
+13
-1
@@ -1,3 +1,15 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 3
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 4
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 5
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 3
|
||||
*/
|
||||
|
||||
fun foo(b: Boolean): Int {
|
||||
val x: Int
|
||||
val y: Int
|
||||
@@ -8,4 +20,4 @@ fun foo(b: Boolean): Int {
|
||||
// x is initialized here
|
||||
x = 3
|
||||
return x + y
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@ fun foo(b: Boolean): Int {
|
||||
// x is initialized here
|
||||
x = 3
|
||||
return x + y
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 10
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 3
|
||||
*/
|
||||
|
||||
enum class MyEnum {
|
||||
A, B
|
||||
}
|
||||
@@ -11,4 +22,4 @@ fun foo(x: MyEnum?): Int {
|
||||
null -> y = 0
|
||||
}
|
||||
return y
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,4 +22,4 @@ fun foo(x: MyEnum?): Int {
|
||||
null -> y = 0
|
||||
}<!>
|
||||
return y
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-313
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
*/
|
||||
|
||||
// See KT-6399: exhaustive whens on platform enums
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
+9
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 923
|
||||
*/
|
||||
|
||||
// See KT-6399: exhaustive whens on platform enums
|
||||
|
||||
// FILE: J.java
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, conditional-expressions -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, boolean-operators -> paragraph 0 -> sentence 0
|
||||
*/
|
||||
|
||||
enum class Direction {
|
||||
NORTH, SOUTH, WEST, EAST
|
||||
}
|
||||
@@ -10,4 +20,4 @@ fun foo(dir: Direction): Int {
|
||||
Direction.EAST -> return 4
|
||||
}
|
||||
// See KT-1882: no return is needed at the end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@ fun foo(dir: Direction): Int {
|
||||
Direction.EAST -> return 4
|
||||
}<!>
|
||||
// See KT-1882: no return is needed at the end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, conditional-expressions -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, boolean-operators -> paragraph 0 -> sentence 0
|
||||
*/
|
||||
|
||||
enum class Direction {
|
||||
NORTH, SOUTH, WEST, EAST
|
||||
}
|
||||
@@ -11,4 +21,4 @@ fun foo(dir: Direction): Int {
|
||||
}
|
||||
// Error: Unreachable code. Return is not required.
|
||||
if (dir == Direction.SOUTH) return 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,4 @@ fun foo(dir: Direction): Int {
|
||||
}<!>
|
||||
// Error: Unreachable code. Return is not required.
|
||||
<!UNREACHABLE_CODE!>if (dir == Direction.SOUTH) return 2<!>
|
||||
}
|
||||
}
|
||||
|
||||
+13
-1
@@ -1,3 +1,15 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 3
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 3
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 3 -> sentence 2
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 3 -> sentence 3
|
||||
*/
|
||||
|
||||
fun foo(a: Boolean, b: Boolean): Int {
|
||||
val x: Int
|
||||
if (a) {
|
||||
@@ -19,4 +31,4 @@ fun bar(a: Boolean, b: Boolean): Int {
|
||||
false -> x = 3
|
||||
}
|
||||
return <!UNINITIALIZED_VARIABLE!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,4 +31,4 @@ fun bar(a: Boolean, b: Boolean): Int {
|
||||
false -> <!VAL_REASSIGNMENT!>x<!> = 3
|
||||
}
|
||||
return <!UNINITIALIZED_VARIABLE!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 3
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 3
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 3 -> sentence 2
|
||||
*/
|
||||
|
||||
fun foo(a: Boolean, b: Boolean): Int {
|
||||
var x: Int
|
||||
if (a) {
|
||||
@@ -19,4 +30,4 @@ fun bar(a: Boolean, b: Boolean): Int {
|
||||
false -> x = 3
|
||||
}
|
||||
return <!UNINITIALIZED_VARIABLE!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,4 +30,4 @@ fun bar(a: Boolean, b: Boolean): Int {
|
||||
false -> x = 3
|
||||
}
|
||||
return <!UNINITIALIZED_VARIABLE!>x<!>
|
||||
}
|
||||
}
|
||||
|
||||
+10
-1
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
*/
|
||||
|
||||
// KT-7857: when exhaustiveness does not take previous nullability checks into account
|
||||
enum class X { A, B }
|
||||
fun foo(arg: X?): Int {
|
||||
@@ -11,4 +20,4 @@ fun foo(arg: X?): Int {
|
||||
else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@ fun foo(arg: X?): Int {
|
||||
else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, conditional-expressions -> paragraph 1 -> sentence 1
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, boolean-operators -> paragraph 0 -> sentence 0
|
||||
*/
|
||||
|
||||
// KT-7857: when exhaustiveness does not take previous nullability checks into account
|
||||
enum class X { A, B }
|
||||
fun foo(arg: X?): Int {
|
||||
@@ -9,4 +20,4 @@ fun foo(arg: X?): Int {
|
||||
X.B -> 2
|
||||
// else or null branch should not be required here!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,4 +20,4 @@ fun foo(arg: X?): Int {
|
||||
X.B -> 2
|
||||
// else or null branch should not be required here!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 3
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 4
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 5
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
*/
|
||||
|
||||
// KT-7857: when exhaustiveness does not take previous nullability checks into account
|
||||
fun foo(arg: Boolean?): Int {
|
||||
if (arg != null) {
|
||||
@@ -10,4 +21,4 @@ fun foo(arg: Boolean?): Int {
|
||||
else {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,4 +21,4 @@ fun foo(arg: Boolean?): Int {
|
||||
else {
|
||||
return -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, conditional-expressions -> paragraph 1 -> sentence 1
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, boolean-operators -> paragraph 0 -> sentence 0
|
||||
*/
|
||||
|
||||
// KT-7857: when exhaustiveness does not take previous nullability checks into account
|
||||
enum class X { A, B }
|
||||
fun foo(arg: X?): Int {
|
||||
@@ -11,4 +22,4 @@ fun foo(arg: X?): Int {
|
||||
// else or null branch should not be required here!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,4 +22,4 @@ fun foo(arg: X?): Int {
|
||||
// else or null branch should not be required here!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 2
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
*/
|
||||
|
||||
fun foo(x: Int) {
|
||||
val y: Unit = when (x) {
|
||||
2 -> {}
|
||||
3 -> {}
|
||||
}
|
||||
return y
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ fun foo(x: Int) {
|
||||
3 -> {}
|
||||
}
|
||||
return y
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 2
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
*/
|
||||
|
||||
fun foo(x: Int): Any {
|
||||
val v = when (x) {
|
||||
2 -> 0
|
||||
}
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,4 @@ fun foo(x: Int): Any {
|
||||
2 -> 0
|
||||
}
|
||||
return v
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 2
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, function-literals, lambda-literals -> paragraph 10 -> sentence 1
|
||||
*/
|
||||
|
||||
fun foo(x: Int) {
|
||||
r {
|
||||
when (x) {
|
||||
@@ -8,4 +18,4 @@ fun foo(x: Int) {
|
||||
|
||||
fun r(f: () -> Unit) {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,4 @@ fun foo(x: Int) {
|
||||
|
||||
fun r(f: () -> Unit) {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 2
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, function-literals, lambda-literals -> paragraph 10 -> sentence 1
|
||||
* overload-resolution, determining-function-applicability-for-a-specific-call, description -> paragraph 3 -> sentence 3
|
||||
*/
|
||||
|
||||
fun foo(x: Int) {
|
||||
r {
|
||||
when (x) {
|
||||
@@ -8,4 +19,4 @@ fun foo(x: Int) {
|
||||
|
||||
fun r(f: () -> Int) {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -19,4 +19,4 @@ fun foo(x: Int) {
|
||||
|
||||
fun r(f: () -> Int) {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 2
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
*/
|
||||
|
||||
fun foo(x: Int): Any {
|
||||
return when (x) {
|
||||
2 -> 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,4 @@ fun foo(x: Int): Any {
|
||||
return <!NO_ELSE_IN_WHEN!>when<!> (x) {
|
||||
2 -> 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 2
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
*/
|
||||
|
||||
|
||||
fun foo(x: Int) {
|
||||
return when (x) {
|
||||
2 -> {}
|
||||
3 -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@ fun foo(x: Int) {
|
||||
2 -> {}
|
||||
3 -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 3
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 10
|
||||
*/
|
||||
|
||||
// See also: KT-3743
|
||||
fun foo(arg: Boolean?): String {
|
||||
// Must be NOT exhaustive
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
*/
|
||||
|
||||
// See KT-6399: exhaustive whens on platform enums
|
||||
|
||||
// FILE: J.java
|
||||
@@ -17,4 +26,4 @@ fun foo(): Int {
|
||||
return when (J.create()) {
|
||||
J.A -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,4 +26,4 @@ fun foo(): Int {
|
||||
return <!NO_ELSE_IN_WHEN!>when<!> (J.create()) {
|
||||
J.A -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 2
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 3
|
||||
*/
|
||||
|
||||
// Base for KT-6227
|
||||
enum class X { A, B, C, D }
|
||||
|
||||
@@ -8,4 +20,4 @@ fun foo(arg: X): String {
|
||||
X.B -> res = "B"
|
||||
}
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,4 +20,4 @@ fun foo(arg: X): String {
|
||||
X.B -> res = "B"
|
||||
}
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 3
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 3 -> sentence 2
|
||||
*/
|
||||
|
||||
// Base for KT-6227
|
||||
enum class X { A, B, C, D }
|
||||
|
||||
@@ -10,4 +21,4 @@ fun foo(arg: X): String {
|
||||
X.D -> res = "D"
|
||||
}
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,4 +21,4 @@ fun foo(arg: X): String {
|
||||
X.D -> res = "D"
|
||||
}<!>
|
||||
return res
|
||||
}
|
||||
}
|
||||
|
||||
+14
-1
@@ -1,3 +1,16 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 6
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 7
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 2
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 3 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
*/
|
||||
|
||||
sealed class S
|
||||
|
||||
object First : S()
|
||||
@@ -13,4 +26,4 @@ fun foo(s: S) {
|
||||
First -> {}
|
||||
is Derived -> use(s.s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -26,4 +26,4 @@ fun foo(s: S) {
|
||||
First -> {}
|
||||
is Derived -> use(<!DEBUG_INFO_SMARTCAST!>s<!>.s)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -1,3 +1,14 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 2
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
*/
|
||||
|
||||
// KT-7857: when exhaustiveness does not take previous nullability checks into account
|
||||
enum class X { A, B }
|
||||
fun foo(arg: X?): Int {
|
||||
@@ -9,4 +20,4 @@ fun foo(arg: X?): Int {
|
||||
else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,4 +20,4 @@ fun foo(arg: X?): Int {
|
||||
else {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 3
|
||||
* control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 3 -> sentence 2
|
||||
* declarations, classifier-declaration, classifier-initialization -> paragraph 6 -> sentence 4
|
||||
*/
|
||||
|
||||
// See KT-5113
|
||||
enum class E {
|
||||
A,
|
||||
@@ -13,4 +25,4 @@ class Outer(e: E) {
|
||||
E.B -> prop = 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ class Outer(e: E) {
|
||||
E.B -> prop = 2
|
||||
}<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 3
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 6
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 10
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 11
|
||||
*/
|
||||
|
||||
// FILE: MyEnum.java
|
||||
public enum MyEnum {
|
||||
SINGLE;
|
||||
@@ -65,4 +77,4 @@ fun useJava(): String {
|
||||
MyEnum.SINGLE -> "OK"
|
||||
else -> "FAIL" // no warning
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,4 +77,4 @@ fun useJava(): String {
|
||||
MyEnum.SINGLE -> "OK"
|
||||
else -> "FAIL" // no warning
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 2 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1
|
||||
*/
|
||||
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
infix fun Any.sealed(a: Any?) {}
|
||||
@@ -34,4 +43,4 @@ fun foo() {
|
||||
when {
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,4 @@ fun foo() {
|
||||
when {
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 6
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 7
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 8
|
||||
*/
|
||||
|
||||
sealed class A {
|
||||
class B: A() {
|
||||
@@ -19,4 +29,4 @@ fun test(a: A) {
|
||||
is A.B.C -> "C"
|
||||
is D -> "D"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,4 +29,4 @@ fun test(a: A) {
|
||||
is A.B.C -> "C"
|
||||
is D -> "D"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-1
@@ -1,4 +1,17 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 2 -> sentence 5
|
||||
* expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 3
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 5
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 9
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 10
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 11
|
||||
*/
|
||||
|
||||
fun Int.foo() : Boolean = true
|
||||
|
||||
@@ -44,4 +57,4 @@ fun test() {
|
||||
when (z) {
|
||||
else -> 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -57,4 +57,4 @@ fun test() {
|
||||
when (<!UNUSED_EXPRESSION!>z<!>) {
|
||||
else -> <!UNUSED_EXPRESSION!>1<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 1
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, conditional-expressions -> paragraph 2 -> sentence 1
|
||||
* control--and-data-flow-analysis, control-flow-graph, expressions-1, boolean-operators -> paragraph 0 -> sentence 0
|
||||
*/
|
||||
|
||||
fun foo(s: Any): String {
|
||||
val x = when (s) {
|
||||
is String -> s
|
||||
@@ -18,4 +30,4 @@ fun bar(s: Any): String {
|
||||
|
||||
val y: String = x // no error
|
||||
return y
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,4 +30,4 @@ fun bar(s: Any): String {
|
||||
|
||||
val y: String = x // no error
|
||||
return y
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,15 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 1
|
||||
* expressions, conditional-expression -> paragraph 4 -> sentence 1
|
||||
* expressions, conditional-expression -> paragraph 5 -> sentence 1
|
||||
* overload-resolution, determining-function-applicability-for-a-specific-call, rationale -> paragraph 1 -> sentence 1
|
||||
* overload-resolution, determining-function-applicability-for-a-specific-call, description -> paragraph 3 -> sentence 1
|
||||
*/
|
||||
|
||||
fun foo(x: Int) = x
|
||||
|
||||
|
||||
+4
-4
@@ -14,12 +14,12 @@
|
||||
fun foo(x: Int) = x
|
||||
|
||||
fun test0(flag: Boolean) {
|
||||
foo(<!NI;TYPE_MISMATCH!>if (flag) <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>true<!> else <!OI;TYPE_MISMATCH!>""<!><!>)
|
||||
foo(<!TYPE_MISMATCH{NI}!>if (flag) <!CONSTANT_EXPECTED_TYPE_MISMATCH{OI}!>true<!> else <!TYPE_MISMATCH{OI}!>""<!><!>)
|
||||
}
|
||||
|
||||
fun test1(flag: Boolean) {
|
||||
foo(<!NI;TYPE_MISMATCH!>when (flag) {
|
||||
true -> <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>true<!>
|
||||
else -> <!OI;TYPE_MISMATCH!>""<!>
|
||||
foo(<!TYPE_MISMATCH{NI}!>when (flag) {
|
||||
true -> <!CONSTANT_EXPECTED_TYPE_MISMATCH{OI}!>true<!>
|
||||
else -> <!TYPE_MISMATCH{OI}!>""<!>
|
||||
}<!>)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_SMARTCAST
|
||||
// NI_EXPECTED_FILE
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 2 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1
|
||||
* expressions, conditional-expression -> paragraph 4 -> sentence 1
|
||||
* declarations, function-declaration -> paragraph 7 -> sentence 1
|
||||
* type-inference, smart-casts, smart-cast-types -> paragraph 9 -> sentence 1
|
||||
* type-system, type-kinds, type-parameters -> paragraph 4 -> sentence 1
|
||||
* type-inference, local-type-inference -> paragraph 8 -> sentence 1
|
||||
* type-inference, local-type-inference -> paragraph 2 -> sentence 1
|
||||
*/
|
||||
|
||||
interface Data
|
||||
interface Item
|
||||
|
||||
+2
-2
@@ -25,7 +25,7 @@ class ListData<T : Item>(val list: List<T>) : Data
|
||||
|
||||
fun <T> listOf(vararg items: T): List<T> = null!!
|
||||
|
||||
fun test1(o: Any) = <!OI;TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT!>when<!> (o) {
|
||||
fun test1(o: Any) = <!TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT{OI}!>when<!> (o) {
|
||||
is List<*> ->
|
||||
ListData(listOf())
|
||||
is Int -> when {
|
||||
@@ -52,7 +52,7 @@ fun test1x(o: Any): Data? = when (o) {
|
||||
}
|
||||
|
||||
fun test2() =
|
||||
<!OI;TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT!>if<!> (true)
|
||||
<!TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT{OI}!>if<!> (true)
|
||||
ListData(listOf())
|
||||
else
|
||||
FlagData(true)
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 5 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 6 -> sentence 5
|
||||
*/
|
||||
|
||||
// KT-4434 Missed diagnostic about else branch in when
|
||||
|
||||
package test
|
||||
|
||||
+1
-1
@@ -7,4 +7,4 @@ val test: Int = if (true) {
|
||||
}
|
||||
else {
|
||||
2
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
val test: Int = if (true) <!NI;TYPE_MISMATCH!>{
|
||||
val test: Int = if (true) <!TYPE_MISMATCH{NI}!>{
|
||||
when (2) {
|
||||
1 -> 1
|
||||
else -> <!OI;NULL_FOR_NONNULL_TYPE!>null<!>
|
||||
else -> <!NULL_FOR_NONNULL_TYPE{OI}!>null<!>
|
||||
}
|
||||
}<!>
|
||||
else {
|
||||
2
|
||||
}
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,4 +1,14 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (POSITIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 2 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1
|
||||
* expressions, when-expression -> paragraph 9 -> sentence 1
|
||||
* expressions, conditional-expression -> paragraph 4 -> sentence 1
|
||||
* expressions, conditional-expression -> paragraph 5 -> sentence 1
|
||||
*/
|
||||
|
||||
fun test1(): Int {
|
||||
val x: String = if (true) {
|
||||
@@ -16,4 +26,4 @@ fun test2(): Int {
|
||||
else -> null
|
||||
} ?: return 0
|
||||
return x.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -11,19 +11,19 @@
|
||||
*/
|
||||
|
||||
fun test1(): Int {
|
||||
val x: String = if (true) <!NI;TYPE_MISMATCH!>{
|
||||
val x: String = if (true) <!TYPE_MISMATCH{NI}!>{
|
||||
when {
|
||||
true -> <!OI;TYPE_MISMATCH!>Any()<!>
|
||||
else -> <!OI;NULL_FOR_NONNULL_TYPE!>null<!>
|
||||
true -> <!TYPE_MISMATCH{OI}!>Any()<!>
|
||||
else -> <!NULL_FOR_NONNULL_TYPE{OI}!>null<!>
|
||||
}
|
||||
}<!> else ""
|
||||
return x.hashCode()
|
||||
}
|
||||
|
||||
fun test2(): Int {
|
||||
val x: String = <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!>when {
|
||||
true -> <!OI;TYPE_MISMATCH!>Any()<!>
|
||||
val x: String = <!TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>when {
|
||||
true -> <!TYPE_MISMATCH{OI}!>Any()<!>
|
||||
else -> null
|
||||
} ?: return 0<!>
|
||||
return x.hashCode()
|
||||
}
|
||||
}
|
||||
|
||||
+10
@@ -1,4 +1,14 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 2 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1
|
||||
* type-system, subtyping, subtyping-rules -> paragraph 2 -> sentence 1
|
||||
* type-inference, local-type-inference -> paragraph 2 -> sentence 1
|
||||
* overload-resolution, determining-function-applicability-for-a-specific-call, description -> paragraph 3 -> sentence 3
|
||||
*/
|
||||
|
||||
val test1: (String) -> Boolean =
|
||||
when {
|
||||
|
||||
@@ -30,7 +30,7 @@ val test3: (String) -> Boolean =
|
||||
|
||||
val test4: (String) -> Boolean =
|
||||
when {
|
||||
true -> <!NI;TYPE_MISMATCH!>{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!UNUSED_ANONYMOUS_PARAMETER!>s1<!>, <!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>s2<!><!> -> true }<!>
|
||||
true -> <!TYPE_MISMATCH{NI}!>{ <!EXPECTED_PARAMETERS_NUMBER_MISMATCH!><!UNUSED_ANONYMOUS_PARAMETER!>s1<!>, <!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>s2<!><!> -> true }<!>
|
||||
else -> null!!
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// NI_EXPECTED_FILE
|
||||
/*
|
||||
* KOTLIN DIAGNOSTICS SPEC TEST (NEGATIVE)
|
||||
*
|
||||
* SPEC VERSION: 0.1-152
|
||||
* PRIMARY LINKS: expressions, when-expression -> paragraph 2 -> sentence 1
|
||||
* expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1
|
||||
* declarations, function-declaration -> paragraph 7 -> sentence 1
|
||||
* declarations, function-declaration -> paragraph 7 -> sentence 2
|
||||
* declarations, function-declaration -> paragraph 8 -> sentence 1
|
||||
* overload-resolution, determining-function-applicability-for-a-specific-call, description -> paragraph 1 -> sentence 3
|
||||
*/
|
||||
|
||||
val test1 = when {
|
||||
true -> { { true } }
|
||||
@@ -37,4 +48,4 @@ val test3a: () -> Boolean = when {
|
||||
true -> { { true } }
|
||||
true -> { { true } }
|
||||
else -> TODO()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
* overload-resolution, determining-function-applicability-for-a-specific-call, description -> paragraph 1 -> sentence 3
|
||||
*/
|
||||
|
||||
val <!OI;IMPLICIT_NOTHING_PROPERTY_TYPE!>test1<!> = when {
|
||||
true -> { <!OI;TYPE_MISMATCH!>{ true }<!> }
|
||||
val <!IMPLICIT_NOTHING_PROPERTY_TYPE{OI}!>test1<!> = when {
|
||||
true -> { <!TYPE_MISMATCH{OI}!>{ true }<!> }
|
||||
else -> TODO()
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ val test1a: () -> Boolean = when {
|
||||
else -> TODO()
|
||||
}
|
||||
|
||||
val <!OI;IMPLICIT_NOTHING_PROPERTY_TYPE!>test2<!> = when {
|
||||
true -> { <!OI;TYPE_MISMATCH!>{ true }<!> }
|
||||
val <!IMPLICIT_NOTHING_PROPERTY_TYPE{OI}!>test2<!> = when {
|
||||
true -> { <!TYPE_MISMATCH{OI}!>{ true }<!> }
|
||||
else -> when {
|
||||
true -> { <!OI;TYPE_MISMATCH!>{ true }<!> }
|
||||
true -> { <!TYPE_MISMATCH{OI}!>{ true }<!> }
|
||||
else -> TODO()
|
||||
}
|
||||
}
|
||||
@@ -33,14 +33,14 @@ val <!OI;IMPLICIT_NOTHING_PROPERTY_TYPE!>test2<!> = when {
|
||||
val test2a: () -> Boolean = when {
|
||||
true -> { { true } }
|
||||
else -> when {
|
||||
true -> { <!OI;TYPE_MISMATCH!>{ true }<!> } // TODO
|
||||
true -> { <!TYPE_MISMATCH{OI}!>{ true }<!> } // TODO
|
||||
else -> TODO()
|
||||
}
|
||||
}
|
||||
|
||||
val <!OI;IMPLICIT_NOTHING_PROPERTY_TYPE!>test3<!> = when {
|
||||
true -> { <!OI;TYPE_MISMATCH!>{ true }<!> }
|
||||
true -> { <!OI;TYPE_MISMATCH!>{ true }<!> }
|
||||
val <!IMPLICIT_NOTHING_PROPERTY_TYPE{OI}!>test3<!> = when {
|
||||
true -> { <!TYPE_MISMATCH{OI}!>{ true }<!> }
|
||||
true -> { <!TYPE_MISMATCH{OI}!>{ true }<!> }
|
||||
else -> TODO()
|
||||
}
|
||||
|
||||
@@ -48,4 +48,4 @@ val test3a: () -> Boolean = when {
|
||||
true -> { { true } }
|
||||
true -> { { true } }
|
||||
else -> TODO()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user