diff --git a/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.kt b/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.kt index 9b4ffaea195..9eab256fd64 100644 --- a/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.kt +++ b/compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.kt @@ -1,4 +1,11 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - expressions, when-expression -> paragraph 9 -> sentence 2 + * - expressions, when-expression -> paragraph 5 -> sentence 1 + * - expressions, when-expression -> paragraph 6 -> sentence 5 + * - annotations, annotation-targets -> paragraph 1 -> sentence 1 + */ fun foo(a: Int) { @ann when (a) { diff --git a/compiler/testData/diagnostics/tests/when/BranchBypassVal.kt b/compiler/testData/diagnostics/tests/when/BranchBypassVal.kt index 7268250c185..8c8d9a6672f 100644 --- a/compiler/testData/diagnostics/tests/when/BranchBypassVal.kt +++ b/compiler/testData/diagnostics/tests/when/BranchBypassVal.kt @@ -1,4 +1,12 @@ // !WITH_NEW_INFERENCE +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 { diff --git a/compiler/testData/diagnostics/tests/when/BranchBypassVar.kt b/compiler/testData/diagnostics/tests/when/BranchBypassVar.kt index df496b12bfe..16a084cbd74 100644 --- a/compiler/testData/diagnostics/tests/when/BranchBypassVar.kt +++ b/compiler/testData/diagnostics/tests/when/BranchBypassVar.kt @@ -1,4 +1,12 @@ // !WITH_NEW_INFERENCE +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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) { diff --git a/compiler/testData/diagnostics/tests/when/BranchFalseBypass.kt b/compiler/testData/diagnostics/tests/when/BranchFalseBypass.kt index 2b7718f0672..7ea30c075c8 100644 --- a/compiler/testData/diagnostics/tests/when/BranchFalseBypass.kt +++ b/compiler/testData/diagnostics/tests/when/BranchFalseBypass.kt @@ -1,3 +1,11 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 { @@ -7,6 +15,6 @@ fun test(a: My): String { My.A -> q = "1" My.B -> q = "2" } - // When is exhaustive + // When is exhaustives return q } diff --git a/compiler/testData/diagnostics/tests/when/BranchFalseBypassElse.kt b/compiler/testData/diagnostics/tests/when/BranchFalseBypassElse.kt index 243c604e05e..fb48b8728cc 100644 --- a/compiler/testData/diagnostics/tests/when/BranchFalseBypassElse.kt +++ b/compiler/testData/diagnostics/tests/when/BranchFalseBypassElse.kt @@ -1,3 +1,11 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 { @@ -7,6 +15,6 @@ fun test(a: Any): String { is A -> q = "1" else -> q = "2" } - // When is not exhaustive + // When is exhaustives return q } diff --git a/compiler/testData/diagnostics/tests/when/CommaInWhenConditionWithoutArgument.kt b/compiler/testData/diagnostics/tests/when/CommaInWhenConditionWithoutArgument.kt index dc2196b015e..7094e0a283e 100644 --- a/compiler/testData/diagnostics/tests/when/CommaInWhenConditionWithoutArgument.kt +++ b/compiler/testData/diagnostics/tests/when/CommaInWhenConditionWithoutArgument.kt @@ -1,3 +1,8 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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,, x < 0 -> 1 diff --git a/compiler/testData/diagnostics/tests/when/DuplicatedLabels.kt b/compiler/testData/diagnostics/tests/when/DuplicatedLabels.kt index 4661ede0dea..6cb2a8c6cd7 100644 --- a/compiler/testData/diagnostics/tests/when/DuplicatedLabels.kt +++ b/compiler/testData/diagnostics/tests/when/DuplicatedLabels.kt @@ -1,3 +1,11 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/ElseOnNullableEnum.kt b/compiler/testData/diagnostics/tests/when/ElseOnNullableEnum.kt index 867e95d1cce..bc48906435c 100644 --- a/compiler/testData/diagnostics/tests/when/ElseOnNullableEnum.kt +++ b/compiler/testData/diagnostics/tests/when/ElseOnNullableEnum.kt @@ -1,4 +1,10 @@ // KT-2902 Check for null should be required when match nullable enum element +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/ElseOnNullableEnumWithSmartCast.kt b/compiler/testData/diagnostics/tests/when/ElseOnNullableEnumWithSmartCast.kt index 0a07c528544..3a82841e504 100644 --- a/compiler/testData/diagnostics/tests/when/ElseOnNullableEnumWithSmartCast.kt +++ b/compiler/testData/diagnostics/tests/when/ElseOnNullableEnumWithSmartCast.kt @@ -1,3 +1,10 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 { diff --git a/compiler/testData/diagnostics/tests/when/EmptyConditionWithExpression.kt b/compiler/testData/diagnostics/tests/when/EmptyConditionWithExpression.kt index ee037778742..9d67d7fb2b5 100644 --- a/compiler/testData/diagnostics/tests/when/EmptyConditionWithExpression.kt +++ b/compiler/testData/diagnostics/tests/when/EmptyConditionWithExpression.kt @@ -1,4 +1,12 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - expressions, when-expression -> paragraph 5 -> sentence 1 + * - expressions, when-expression -> paragraph 1 -> sentence 1 + * - expressions, when-expression -> paragraph 1 -> sentence 2 + * - expressions, when-expression -> paragraph 6 -> sentence 5 + */ + // EA-68871: empty when condition fun foo(arg: Int): Int { when (arg) { diff --git a/compiler/testData/diagnostics/tests/when/EmptyConditionWithExpressionEnum.kt b/compiler/testData/diagnostics/tests/when/EmptyConditionWithExpressionEnum.kt index 5f76624fbbc..cf1c8b3fe68 100644 --- a/compiler/testData/diagnostics/tests/when/EmptyConditionWithExpressionEnum.kt +++ b/compiler/testData/diagnostics/tests/when/EmptyConditionWithExpressionEnum.kt @@ -1,4 +1,12 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - expressions, when-expression -> paragraph 5 -> sentence 1 + * - expressions, when-expression -> paragraph 1 -> sentence 1 + * - expressions, when-expression -> paragraph 1 -> sentence 2 + * - expressions, when-expression -> paragraph 6 -> sentence 5 + */ + // EA-68871: empty when condition enum class My { FIRST, SECOND } fun foo(arg: My): Int { diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveBoolean.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveBoolean.kt index 48908f00e38..bf9803b912b 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveBoolean.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveBoolean.kt @@ -1,4 +1,12 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 + */ + // See also: KT-3743 fun foo(arg: Boolean): String { // Must be exhaustive diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanBrackets.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanBrackets.kt index 32fcf43d05f..f68dcdb5446 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanBrackets.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanBrackets.kt @@ -1,4 +1,12 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 + */ + fun foo(arg: Boolean): String { // Must be exhaustive return when(arg) { diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanComplex.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanComplex.kt index a74eac28612..81d5aa5ee17 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanComplex.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanComplex.kt @@ -1,4 +1,12 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 + */ + // See also: KT-3743 fun foo(arg: Boolean): String { // Must be exhaustive diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanNullable.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanNullable.kt index 8a757837941..53a902d7d9e 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanNullable.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveBooleanNullable.kt @@ -1,4 +1,12 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 10 + */ + // See also: KT-3743 fun foo(arg: Boolean?): String { // Must be exhaustive diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveBreakContinue.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveBreakContinue.kt index 0ecd8c7b8b4..95545202ce5 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveBreakContinue.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveBreakContinue.kt @@ -1,3 +1,12 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 { diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveEnumIs.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveEnumIs.kt index 0e5b31d342f..cdb933eb240 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveEnumIs.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveEnumIs.kt @@ -1,3 +1,10 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 } diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveEnumMixed.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveEnumMixed.kt index d962fadd7e4..c56933375f4 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveEnumMixed.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveEnumMixed.kt @@ -1,3 +1,11 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 } diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveInitialization.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveInitialization.kt index 3364fa57dbc..7cf0d18514f 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveInitialization.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveInitialization.kt @@ -1,3 +1,12 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 +21,4 @@ fun foo(dir: Direction): Int { Direction.EAST -> res = 4 } return res -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveNoInitialization.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveNoInitialization.kt index f55818abc2e..ceb6ff9403e 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveNoInitialization.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveNoInitialization.kt @@ -1,3 +1,13 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveNullable.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveNullable.kt index 43630bdaa59..e0e5ed4424d 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveNullable.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveNullable.kt @@ -1,3 +1,12 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 } diff --git a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnum.kt b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnum.kt index dff3fe24e60..da3ede407d4 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnum.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnum.kt @@ -1,3 +1,9 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumAnnotated.kt b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumAnnotated.kt index c8c063e5548..bd3608dd00e 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumAnnotated.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumAnnotated.kt @@ -1,4 +1,10 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumElse.kt b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumElse.kt index ae4fe9423c9..9abfea20185 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumElse.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumElse.kt @@ -1,4 +1,11 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - expressions, when-expression -> paragraph 5 -> sentence 1 + * - expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1 + * - expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9 + */ + // See KT-6399: exhaustive whens on platform enums // FILE: J.java diff --git a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumNull.kt b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumNull.kt index 1fcd73bf120..073be24a263 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumNull.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumNull.kt @@ -1,4 +1,11 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 + */ + // See KT-6399: exhaustive whens on platform enums // FILE: J.java diff --git a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumStatement.kt b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumStatement.kt index 99817bb4182..b0fa7677b3f 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumStatement.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumStatement.kt @@ -1,3 +1,9 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveReturn.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveReturn.kt index a1dd5472dfa..7a0945ca2a7 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveReturn.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveReturn.kt @@ -1,3 +1,11 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 } diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveReturnThrow.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveReturnThrow.kt index 2171e817aab..4ee8fb00b47 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveReturnThrow.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveReturnThrow.kt @@ -1,3 +1,11 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 } diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveValOverConditionalInit.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveValOverConditionalInit.kt index c3e37e00e7c..059949c0482 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveValOverConditionalInit.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveValOverConditionalInit.kt @@ -1,3 +1,13 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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) { diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveVarOverConditionalInit.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveVarOverConditionalInit.kt index c0d98cd7d74..d4821881a1b 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveVarOverConditionalInit.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveVarOverConditionalInit.kt @@ -1,3 +1,12 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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) { diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheck.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheck.kt index d140b62eb6f..d3de81349a2 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheck.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheck.kt @@ -1,3 +1,10 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 { diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBefore.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBefore.kt index 194c0dafe0a..5254d3728b8 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBefore.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBefore.kt @@ -1,3 +1,12 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 { diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBoolean.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBoolean.kt index 351bd904902..70a2bd40a8e 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBoolean.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBoolean.kt @@ -1,3 +1,12 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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) { diff --git a/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckElse.kt b/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckElse.kt index a301f843b80..cea7c51ba4b 100644 --- a/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckElse.kt +++ b/compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckElse.kt @@ -1,3 +1,12 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 { diff --git a/compiler/testData/diagnostics/tests/when/NoElseExpectedUnit.kt b/compiler/testData/diagnostics/tests/when/NoElseExpectedUnit.kt index 6ec8570e4e4..9df5ef3bb3b 100644 --- a/compiler/testData/diagnostics/tests/when/NoElseExpectedUnit.kt +++ b/compiler/testData/diagnostics/tests/when/NoElseExpectedUnit.kt @@ -1,3 +1,10 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 -> {} diff --git a/compiler/testData/diagnostics/tests/when/NoElseNoExpectedType.kt b/compiler/testData/diagnostics/tests/when/NoElseNoExpectedType.kt index 7fa7ba2c583..2f738c0c335 100644 --- a/compiler/testData/diagnostics/tests/when/NoElseNoExpectedType.kt +++ b/compiler/testData/diagnostics/tests/when/NoElseNoExpectedType.kt @@ -1,3 +1,10 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/NoElseReturnedCoercionToUnit.kt b/compiler/testData/diagnostics/tests/when/NoElseReturnedCoercionToUnit.kt index 4c0f410c0f2..096513ac0f6 100644 --- a/compiler/testData/diagnostics/tests/when/NoElseReturnedCoercionToUnit.kt +++ b/compiler/testData/diagnostics/tests/when/NoElseReturnedCoercionToUnit.kt @@ -1,3 +1,11 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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) { diff --git a/compiler/testData/diagnostics/tests/when/NoElseReturnedFromLambdaExpectedInt.kt b/compiler/testData/diagnostics/tests/when/NoElseReturnedFromLambdaExpectedInt.kt index 44dc8fb1315..745e354bde2 100644 --- a/compiler/testData/diagnostics/tests/when/NoElseReturnedFromLambdaExpectedInt.kt +++ b/compiler/testData/diagnostics/tests/when/NoElseReturnedFromLambdaExpectedInt.kt @@ -1,3 +1,12 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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) { diff --git a/compiler/testData/diagnostics/tests/when/NoElseReturnedNonUnit.kt b/compiler/testData/diagnostics/tests/when/NoElseReturnedNonUnit.kt index c0f1d665ae8..8b921a2cb9f 100644 --- a/compiler/testData/diagnostics/tests/when/NoElseReturnedNonUnit.kt +++ b/compiler/testData/diagnostics/tests/when/NoElseReturnedNonUnit.kt @@ -1,3 +1,10 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/NoElseReturnedUnit.kt b/compiler/testData/diagnostics/tests/when/NoElseReturnedUnit.kt index 8260884dd5f..23dbd7f887e 100644 --- a/compiler/testData/diagnostics/tests/when/NoElseReturnedUnit.kt +++ b/compiler/testData/diagnostics/tests/when/NoElseReturnedUnit.kt @@ -1,3 +1,11 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 -> {} diff --git a/compiler/testData/diagnostics/tests/when/NoElseWhenStatement.kt b/compiler/testData/diagnostics/tests/when/NoElseWhenStatement.kt index 54e19bc0930..b2f192fdb66 100644 --- a/compiler/testData/diagnostics/tests/when/NoElseWhenStatement.kt +++ b/compiler/testData/diagnostics/tests/when/NoElseWhenStatement.kt @@ -1,4 +1,10 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - expressions, when-expression -> paragraph 5 -> sentence 1 + * - expressions, when-expression -> paragraph 9 -> sentence 2 + */ + fun foo(x: Int) { when (x) { 2 -> {} diff --git a/compiler/testData/diagnostics/tests/when/NonExhaustiveBooleanNullable.kt b/compiler/testData/diagnostics/tests/when/NonExhaustiveBooleanNullable.kt index dfef6062c44..5cea7ab9a56 100644 --- a/compiler/testData/diagnostics/tests/when/NonExhaustiveBooleanNullable.kt +++ b/compiler/testData/diagnostics/tests/when/NonExhaustiveBooleanNullable.kt @@ -1,3 +1,11 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/NonExhaustivePlatformEnum.kt b/compiler/testData/diagnostics/tests/when/NonExhaustivePlatformEnum.kt index da8465bb7dd..472c6d4ec32 100644 --- a/compiler/testData/diagnostics/tests/when/NonExhaustivePlatformEnum.kt +++ b/compiler/testData/diagnostics/tests/when/NonExhaustivePlatformEnum.kt @@ -1,3 +1,10 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarning.kt b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarning.kt index fea80b4b2c8..b11dd3c4a39 100644 --- a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarning.kt +++ b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarning.kt @@ -1,3 +1,13 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 } diff --git a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningElse.kt b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningElse.kt index cdf60606abc..1dc9dbed689 100644 --- a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningElse.kt +++ b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningElse.kt @@ -1,4 +1,14 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 1 + * - 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 } diff --git a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningFalse.kt b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningFalse.kt index 1304db0191a..2f927561bab 100644 --- a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningFalse.kt +++ b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningFalse.kt @@ -1,3 +1,12 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 } diff --git a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt index 66d9dcea181..fd5d3dbae14 100644 --- a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt +++ b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt @@ -1,3 +1,14 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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() diff --git a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt index 674565a60b0..1691f8812dc 100644 --- a/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt +++ b/compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt @@ -1,4 +1,15 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - expressions, when-expression -> paragraph 5 -> sentence 1 + * - expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1 + * - expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 9 + * - expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 10 + * - expressions, when-expression -> paragraph 9 -> sentence 2 + * - control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 1 + * - control--and-data-flow-analysis, performing-analysis-on-the-control-flow-graph, variable-initialization-analysis -> paragraph 2 -> sentence 3 + */ + // Base for KT-6227 enum class X { A, B, C, D } diff --git a/compiler/testData/diagnostics/tests/when/NonExhaustiveWithNullabilityCheck.kt b/compiler/testData/diagnostics/tests/when/NonExhaustiveWithNullabilityCheck.kt index 6af95a177ff..dc7a4ab0956 100644 --- a/compiler/testData/diagnostics/tests/when/NonExhaustiveWithNullabilityCheck.kt +++ b/compiler/testData/diagnostics/tests/when/NonExhaustiveWithNullabilityCheck.kt @@ -1,3 +1,12 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 { diff --git a/compiler/testData/diagnostics/tests/when/PropertyNotInitialized.kt b/compiler/testData/diagnostics/tests/when/PropertyNotInitialized.kt index 09e7a8ca35f..258d9b997f2 100644 --- a/compiler/testData/diagnostics/tests/when/PropertyNotInitialized.kt +++ b/compiler/testData/diagnostics/tests/when/PropertyNotInitialized.kt @@ -1,3 +1,13 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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, diff --git a/compiler/testData/diagnostics/tests/when/RedundantElse.kt b/compiler/testData/diagnostics/tests/when/RedundantElse.kt index 0ae9720eb72..72d6fec511b 100644 --- a/compiler/testData/diagnostics/tests/when/RedundantElse.kt +++ b/compiler/testData/diagnostics/tests/when/RedundantElse.kt @@ -1,3 +1,13 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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; diff --git a/compiler/testData/diagnostics/tests/when/ReservedExhaustiveWhen.kt b/compiler/testData/diagnostics/tests/when/ReservedExhaustiveWhen.kt index dfbb7a98d87..03599a12c51 100644 --- a/compiler/testData/diagnostics/tests/when/ReservedExhaustiveWhen.kt +++ b/compiler/testData/diagnostics/tests/when/ReservedExhaustiveWhen.kt @@ -1,3 +1,10 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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?) {} diff --git a/compiler/testData/diagnostics/tests/when/TopLevelSealed.kt b/compiler/testData/diagnostics/tests/when/TopLevelSealed.kt index 6f75a142283..61c2344d0b8 100644 --- a/compiler/testData/diagnostics/tests/when/TopLevelSealed.kt +++ b/compiler/testData/diagnostics/tests/when/TopLevelSealed.kt @@ -1,4 +1,12 @@ // !DIAGNOSTICS: -UNUSED_VARIABLE +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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() { diff --git a/compiler/testData/diagnostics/tests/when/When.kt b/compiler/testData/diagnostics/tests/when/When.kt index dd05a58070e..b7ceebd10b0 100644 --- a/compiler/testData/diagnostics/tests/when/When.kt +++ b/compiler/testData/diagnostics/tests/when/When.kt @@ -1,4 +1,16 @@ // !WITH_NEW_INFERENCE +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 fun foo() : Int { diff --git a/compiler/testData/diagnostics/tests/when/WhenTypeDisjunctions.kt b/compiler/testData/diagnostics/tests/when/WhenTypeDisjunctions.kt index 84e142ee6b8..599a88ead5a 100644 --- a/compiler/testData/diagnostics/tests/when/WhenTypeDisjunctions.kt +++ b/compiler/testData/diagnostics/tests/when/WhenTypeDisjunctions.kt @@ -1,3 +1,13 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/kt10439.kt b/compiler/testData/diagnostics/tests/when/kt10439.kt index c20c63d840a..c73f5c2be66 100644 --- a/compiler/testData/diagnostics/tests/when/kt10439.kt +++ b/compiler/testData/diagnostics/tests/when/kt10439.kt @@ -1,4 +1,14 @@ // !WITH_NEW_INFERENCE +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 fun test0(flag: Boolean) { diff --git a/compiler/testData/diagnostics/tests/when/kt10809.kt b/compiler/testData/diagnostics/tests/when/kt10809.kt index b75b572a899..820ceb4c9b1 100644 --- a/compiler/testData/diagnostics/tests/when/kt10809.kt +++ b/compiler/testData/diagnostics/tests/when/kt10809.kt @@ -1,6 +1,20 @@ // !WITH_NEW_INFERENCE // !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_SMARTCAST // NI_EXPECTED_FILE +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/kt10811.kt b/compiler/testData/diagnostics/tests/when/kt10811.kt index 82041313430..7c5b1fdd699 100644 --- a/compiler/testData/diagnostics/tests/when/kt10811.kt +++ b/compiler/testData/diagnostics/tests/when/kt10811.kt @@ -1,4 +1,17 @@ // FIR_IDENTICAL +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - expressions, when-expression -> paragraph 2 -> sentence 1 + * - expressions, when-expression -> paragraph 5 -> sentence 1 + * - expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1 + * - expressions, conditional-expression -> paragraph 4 -> sentence 1 + * - type-inference, local-type-inference -> paragraph 8 -> sentence 1 + * - type-inference, local-type-inference -> paragraph 2 -> sentence 1 + * - type-system, subtyping, subtyping-rules -> paragraph 2 -> sentence 3 + * - type-system, subtyping, subtyping-for-nullable-types -> paragraph 4 -> sentence 1 + * - type-system, subtyping, subtyping-for-nullable-types -> paragraph 4 -> sentence 2 + */ + interface Maybe class Some(val value: T) : Maybe class None : Maybe diff --git a/compiler/testData/diagnostics/tests/when/kt4434.kt b/compiler/testData/diagnostics/tests/when/kt4434.kt index 18116da4566..be0d1e00df3 100644 --- a/compiler/testData/diagnostics/tests/when/kt4434.kt +++ b/compiler/testData/diagnostics/tests/when/kt4434.kt @@ -1,3 +1,11 @@ +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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 diff --git a/compiler/testData/diagnostics/tests/when/kt9972.kt b/compiler/testData/diagnostics/tests/when/kt9972.kt index 787d04cbe47..1a950e4cbb4 100644 --- a/compiler/testData/diagnostics/tests/when/kt9972.kt +++ b/compiler/testData/diagnostics/tests/when/kt9972.kt @@ -1,4 +1,13 @@ // !WITH_NEW_INFERENCE +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: pos): + * - 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) { when { diff --git a/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt b/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt index 4011f9bdcc4..72c6dc575c7 100644 --- a/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt +++ b/compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt @@ -1,4 +1,13 @@ // !WITH_NEW_INFERENCE +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 { true -> {{ true }} diff --git a/compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt b/compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt index 51c460c3797..2bb1ec1d644 100644 --- a/compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt +++ b/compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt @@ -1,5 +1,15 @@ // !WITH_NEW_INFERENCE // NI_EXPECTED_FILE +/* + * RELEVANT SPEC SENTENCES (spec version: 0.1-155, test type: neg): + * - 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 } } else -> TODO() diff --git a/compiler/tests-spec/testData/diagnostics/linked/annotations/annotation-targets/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/annotations/annotation-targets/testsMap.json new file mode 100644 index 00000000000..019e1cc9724 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/annotations/annotation-targets/testsMap.json @@ -0,0 +1,15 @@ +{ + "1": { + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Annotated when statement", + "path": "compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph/variable-initialization-analysis/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph/variable-initialization-analysis/testsMap.json new file mode 100644 index 00000000000..a46a061a597 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/control--and-data-flow-analysis/performing-analysis-on-the-control-flow-graph/variable-initialization-analysis/testsMap.json @@ -0,0 +1,206 @@ +{ + "2": { + "neg": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning null", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarning.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive val over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveValOverConditionalInit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning false", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningFalse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive var over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveVarOverConditionalInit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Property not initialized", + "path": "compiler/testData/diagnostics/tests/when/PropertyNotInitialized.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning else", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningElse.kt", + "unexpectedBehaviour": false + } + ], + "3": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning null", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarning.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive val over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveValOverConditionalInit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning false", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningFalse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive var over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveVarOverConditionalInit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Property not initialized", + "path": "compiler/testData/diagnostics/tests/when/PropertyNotInitialized.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning else", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningElse.kt", + "unexpectedBehaviour": false + } + ] + }, + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive nullable", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveInitialization.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive no initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNoInitialization.kt", + "unexpectedBehaviour": false + } + ], + "3": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive nullable", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveInitialization.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive no initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNoInitialization.kt", + "unexpectedBehaviour": false + } + ] + } + }, + "3": { + "neg": { + "2": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive val over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveValOverConditionalInit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning false", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningFalse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive var over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveVarOverConditionalInit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Property not initialized", + "path": "compiler/testData/diagnostics/tests/when/PropertyNotInitialized.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning else", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningElse.kt", + "unexpectedBehaviour": false + } + ], + "3": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive val over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveValOverConditionalInit.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/classifier-initialization/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/classifier-initialization/testsMap.json new file mode 100644 index 00000000000..5faf143d208 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/declarations/classifier-declaration/classifier-initialization/testsMap.json @@ -0,0 +1,15 @@ +{ + "6": { + "neg": { + "4": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Property not initialized", + "path": "compiler/testData/diagnostics/tests/when/PropertyNotInitialized.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/declarations/function-declaration/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/declarations/function-declaration/testsMap.json new file mode 100644 index 00000000000..0f532f9541b --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/declarations/function-declaration/testsMap.json @@ -0,0 +1,48 @@ +{ + "7": { + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10809", + "path": "compiler/testData/diagnostics/tests/when/kt10809.kt", + "unexpectedBehaviour": false + } + ] + }, + "neg": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When with nothing and lambdas", + "path": "compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt", + "unexpectedBehaviour": false + } + ], + "2": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When with nothing and lambdas", + "path": "compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt", + "unexpectedBehaviour": false + } + ] + } + }, + "8": { + "neg": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When with nothing and lambdas", + "path": "compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/function-literals/lambda-literals/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/expressions/function-literals/lambda-literals/testsMap.json new file mode 100644 index 00000000000..cda30162670 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/function-literals/lambda-literals/testsMap.json @@ -0,0 +1,22 @@ +{ + "10": { + "neg": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned coercion to unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedCoercionToUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned from lambda expected int", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedFromLambdaExpectedInt.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/exhaustive-when-expressions/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/exhaustive-when-expressions/testsMap.json index fc8bf486751..b04e25ac1e3 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/exhaustive-when-expressions/testsMap.json +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/exhaustive-when-expressions/testsMap.json @@ -19,6 +19,34 @@ "casesNumber": 3, "description": "Non-exhaustive when using nullable boolean values.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean nullable", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning null", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Else on nullable enum", + "path": "compiler/testData/diagnostics/tests/when/ElseOnNullableEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Else on nullable enum with smart cast", + "path": "compiler/testData/diagnostics/tests/when/ElseOnNullableEnumWithSmartCast.kt", + "unexpectedBehaviour": false } ], "1": [ @@ -33,6 +61,41 @@ "casesNumber": 3, "description": "Non-exhaustive when, without bound value, without else branch.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When and lambda with expected type", + "path": "compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When type disjunctions", + "path": "compiler/testData/diagnostics/tests/when/WhenTypeDisjunctions.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Reserved exhaustive when", + "path": "compiler/testData/diagnostics/tests/when/ReservedExhaustiveWhen.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning else", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When with nothing and lambdas", + "path": "compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt", + "unexpectedBehaviour": false } ], "3": [ @@ -41,6 +104,55 @@ "casesNumber": 5, "description": "Non-exhaustive when using boolean values.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean nullable", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive val over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveValOverConditionalInit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean brackets", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanBrackets.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean complex", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanComplex.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBoolean.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive var over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveVarOverConditionalInit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Redundant else", + "path": "compiler/testData/diagnostics/tests/when/RedundantElse.kt", + "unexpectedBehaviour": false } ], "6": [ @@ -49,6 +161,198 @@ "casesNumber": 12, "description": "Non-exhaustive when using subclasses of the sealed class.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning for sealed class", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Redundant else", + "path": "compiler/testData/diagnostics/tests/when/RedundantElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Top level sealed", + "path": "compiler/testData/diagnostics/tests/when/TopLevelSealed.kt", + "unexpectedBehaviour": false + } + ], + "4": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean nullable", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean brackets", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanBrackets.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean complex", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanComplex.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBoolean.kt", + "unexpectedBehaviour": false + } + ], + "9": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning null", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarning.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning false", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningFalse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive platform enum", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustivePlatformEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive enum mixed", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveEnumMixed.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Property not initialized", + "path": "compiler/testData/diagnostics/tests/when/PropertyNotInitialized.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning else", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Redundant else", + "path": "compiler/testData/diagnostics/tests/when/RedundantElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive with nullability check", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWithNullabilityCheck.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive enum is", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveEnumIs.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive break continue", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBreakContinue.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Else on nullable enum", + "path": "compiler/testData/diagnostics/tests/when/ElseOnNullableEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Else on nullable enum with smart cast", + "path": "compiler/testData/diagnostics/tests/when/ElseOnNullableEnumWithSmartCast.kt", + "unexpectedBehaviour": false + } + ], + "5": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean brackets", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanBrackets.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean complex", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanComplex.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBoolean.kt", + "unexpectedBehaviour": false + } + ], + "7": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning for sealed class", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Top level sealed", + "path": "compiler/testData/diagnostics/tests/when/TopLevelSealed.kt", + "unexpectedBehaviour": false + } + ], + "8": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Top level sealed", + "path": "compiler/testData/diagnostics/tests/when/TopLevelSealed.kt", + "unexpectedBehaviour": false } ] }, @@ -71,6 +375,27 @@ "casesNumber": 2, "description": "Exhaustive when using nullable boolean values.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive nullable", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive boolean nullable", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveBooleanNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum null", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumNull.kt", + "unexpectedBehaviour": false } ], "1": [ @@ -91,6 +416,55 @@ "casesNumber": 3, "description": "Exhaustive when, without bound value, with else branch.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum else", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt9929", + "path": "compiler/testData/diagnostics/tests/when/kt9929.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt4434", + "path": "compiler/testData/diagnostics/tests/when/kt4434.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10811", + "path": "compiler/testData/diagnostics/tests/when/kt10811.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt9972", + "path": "compiler/testData/diagnostics/tests/when/kt9972.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch false bypass else", + "path": "compiler/testData/diagnostics/tests/when/BranchFalseBypassElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10809", + "path": "compiler/testData/diagnostics/tests/when/kt10809.kt", + "unexpectedBehaviour": false } ], "3": [ @@ -99,6 +473,27 @@ "casesNumber": 2, "description": "Exhaustive when using boolean values.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check boolean", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBoolean.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive boolean nullable", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveBooleanNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive no initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNoInitialization.kt", + "unexpectedBehaviour": false } ], "8": [ @@ -116,6 +511,266 @@ "description": "Exhaustive when using subclasses of the sealed class.", "unexpectedBehaviour": true } + ], + "9": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum else", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch false bypass", + "path": "compiler/testData/diagnostics/tests/when/BranchFalseBypass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check before", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBefore.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check else", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum statement", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumStatement.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive nullable", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveInitialization.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheck.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum annotated", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumAnnotated.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive return throw", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveReturnThrow.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive return", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveReturn.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum null", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumNull.kt", + "unexpectedBehaviour": false + } + ], + "4": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check boolean", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBoolean.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive no initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNoInitialization.kt", + "unexpectedBehaviour": false + } + ], + "5": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check boolean", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBoolean.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive no initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNoInitialization.kt", + "unexpectedBehaviour": false + } + ] + } + }, + "1": { + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt9929", + "path": "compiler/testData/diagnostics/tests/when/kt9929.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt4434", + "path": "compiler/testData/diagnostics/tests/when/kt4434.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive boolean nullable", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveBooleanNullable.kt", + "unexpectedBehaviour": false + } + ] + }, + "neg": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning null", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else expected unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseExpectedUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch bypass val", + "path": "compiler/testData/diagnostics/tests/when/BranchBypassVal.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarning.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned coercion to unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedCoercionToUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning for sealed class", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch bypass var", + "path": "compiler/testData/diagnostics/tests/when/BranchBypassVar.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive platform enum", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustivePlatformEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned from lambda expected int", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedFromLambdaExpectedInt.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive with nullability check", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWithNullabilityCheck.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else no expected type", + "path": "compiler/testData/diagnostics/tests/when/NoElseNoExpectedType.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned non unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedNonUnit.kt", + "unexpectedBehaviour": false + } + ] + } + }, + "3": { + "neg": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning for sealed class", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt", + "unexpectedBehaviour": false + } ] } } diff --git a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/testsMap.json index 1ae37e8ab23..5b5065aacaf 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/testsMap.json +++ b/compiler/tests-spec/testData/diagnostics/linked/expressions/when-expression/testsMap.json @@ -13,6 +13,55 @@ "casesNumber": 3, "description": "\u0027When\u0027 with bound value and type test condition (without companion object in classes), but without type checking operator.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When type disjunctions", + "path": "compiler/testData/diagnostics/tests/when/WhenTypeDisjunctions.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch bypass val", + "path": "compiler/testData/diagnostics/tests/when/BranchBypassVal.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When", + "path": "compiler/testData/diagnostics/tests/when/When.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch bypass var", + "path": "compiler/testData/diagnostics/tests/when/BranchBypassVar.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive enum mixed", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveEnumMixed.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive enum is", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveEnumIs.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Top level sealed", + "path": "compiler/testData/diagnostics/tests/when/TopLevelSealed.kt", + "unexpectedBehaviour": false } ], "3": [ @@ -27,6 +76,13 @@ "casesNumber": 2, "description": "\u0027When\u0027 with bound value and \u0027when condition\u0027 with contains operator and type without defined contains operator.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When", + "path": "compiler/testData/diagnostics/tests/when/When.kt", + "unexpectedBehaviour": false } ], "9": [ @@ -41,6 +97,13 @@ "casesNumber": 2, "description": "\u0027When\u0027 with bound value and not allowed break and continue expression (without labels) in \u0027when condition\u0027.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When", + "path": "compiler/testData/diagnostics/tests/when/When.kt", + "unexpectedBehaviour": false } ], "6": [ @@ -57,6 +120,66 @@ "casesNumber": 3, "description": "\u0027When\u0027 without bound value and with \u0027else\u0027 branch not in the last position.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When", + "path": "compiler/testData/diagnostics/tests/when/When.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Redundant else", + "path": "compiler/testData/diagnostics/tests/when/RedundantElse.kt", + "unexpectedBehaviour": false + } + ], + "5": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When", + "path": "compiler/testData/diagnostics/tests/when/When.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Empty condition with expression enum", + "path": "compiler/testData/diagnostics/tests/when/EmptyConditionWithExpressionEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive enum mixed", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveEnumMixed.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Empty condition with expression", + "path": "compiler/testData/diagnostics/tests/when/EmptyConditionWithExpression.kt", + "unexpectedBehaviour": false + } + ], + "10": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When", + "path": "compiler/testData/diagnostics/tests/when/When.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Redundant else", + "path": "compiler/testData/diagnostics/tests/when/RedundantElse.kt", + "unexpectedBehaviour": false } ] }, @@ -85,6 +208,27 @@ "casesNumber": 6, "description": "\u0027When\u0027 with bound value and type test condition.", "unexpectedBehaviour": true + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch false bypass", + "path": "compiler/testData/diagnostics/tests/when/BranchFalseBypass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch false bypass else", + "path": "compiler/testData/diagnostics/tests/when/BranchFalseBypassElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10809", + "path": "compiler/testData/diagnostics/tests/when/kt10809.kt", + "unexpectedBehaviour": false } ], "3": [ @@ -130,6 +274,29 @@ "description": "\u0027When\u0027 without bound value and with else branch in the last position.", "unexpectedBehaviour": false } + ], + "5": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Annotated when statement", + "path": "compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt4434", + "path": "compiler/testData/diagnostics/tests/when/kt4434.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveInitialization.kt", + "unexpectedBehaviour": false + } ] } }, @@ -149,6 +316,40 @@ "unexpectedBehaviour": false } ] + }, + "neg": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Empty condition with expression enum", + "path": "compiler/testData/diagnostics/tests/when/EmptyConditionWithExpressionEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Empty condition with expression", + "path": "compiler/testData/diagnostics/tests/when/EmptyConditionWithExpression.kt", + "unexpectedBehaviour": false + } + ], + "2": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Empty condition with expression enum", + "path": "compiler/testData/diagnostics/tests/when/EmptyConditionWithExpressionEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Empty condition with expression", + "path": "compiler/testData/diagnostics/tests/when/EmptyConditionWithExpression.kt", + "unexpectedBehaviour": false + } + ] } }, "4": { @@ -207,6 +408,36 @@ "casesNumber": 2, "description": "Forbidden break and continue in the control structure body of when.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When and lambda with expected type", + "path": "compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Reserved exhaustive when", + "path": "compiler/testData/diagnostics/tests/when/ReservedExhaustiveWhen.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When with nothing and lambdas", + "path": "compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt", + "unexpectedBehaviour": false + } + ], + "5": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When", + "path": "compiler/testData/diagnostics/tests/when/When.kt", + "unexpectedBehaviour": false } ] }, @@ -237,6 +468,52 @@ "casesNumber": 25, "description": "When without bound value, various expressions in the control structure body.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10811", + "path": "compiler/testData/diagnostics/tests/when/kt10811.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt9972", + "path": "compiler/testData/diagnostics/tests/when/kt9972.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Comma in when condition without argument", + "path": "compiler/testData/diagnostics/tests/when/CommaInWhenConditionWithoutArgument.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10809", + "path": "compiler/testData/diagnostics/tests/when/kt10809.kt", + "unexpectedBehaviour": false + } + ], + "4": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Duplicated labels", + "path": "compiler/testData/diagnostics/tests/when/DuplicatedLabels.kt", + "unexpectedBehaviour": false + } + ], + "5": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Duplicated labels", + "path": "compiler/testData/diagnostics/tests/when/DuplicatedLabels.kt", + "unexpectedBehaviour": false } ] } @@ -249,6 +526,244 @@ "casesNumber": 2, "description": "\u0027When\u0027 with bound value and not allowed break and continue expression (without labels) in the control structure body.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When type disjunctions", + "path": "compiler/testData/diagnostics/tests/when/WhenTypeDisjunctions.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean nullable", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning null", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else expected unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseExpectedUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch bypass val", + "path": "compiler/testData/diagnostics/tests/when/BranchBypassVal.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarning.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive val over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveValOverConditionalInit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean brackets", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanBrackets.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When", + "path": "compiler/testData/diagnostics/tests/when/When.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean complex", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBooleanComplex.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned coercion to unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedCoercionToUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning false", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningFalse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning for sealed class", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Reserved exhaustive when", + "path": "compiler/testData/diagnostics/tests/when/ReservedExhaustiveWhen.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive boolean", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBoolean.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch bypass var", + "path": "compiler/testData/diagnostics/tests/when/BranchBypassVar.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive platform enum", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustivePlatformEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned from lambda expected int", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedFromLambdaExpectedInt.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive var over conditional init", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveVarOverConditionalInit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Empty condition with expression enum", + "path": "compiler/testData/diagnostics/tests/when/EmptyConditionWithExpressionEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive enum mixed", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveEnumMixed.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Empty condition with expression", + "path": "compiler/testData/diagnostics/tests/when/EmptyConditionWithExpression.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Property not initialized", + "path": "compiler/testData/diagnostics/tests/when/PropertyNotInitialized.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning else", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Redundant else", + "path": "compiler/testData/diagnostics/tests/when/RedundantElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive with nullability check", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWithNullabilityCheck.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else no expected type", + "path": "compiler/testData/diagnostics/tests/when/NoElseNoExpectedType.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive enum is", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveEnumIs.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned non unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedNonUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive break continue", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveBreakContinue.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Top level sealed", + "path": "compiler/testData/diagnostics/tests/when/TopLevelSealed.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Else on nullable enum", + "path": "compiler/testData/diagnostics/tests/when/ElseOnNullableEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Else on nullable enum with smart cast", + "path": "compiler/testData/diagnostics/tests/when/ElseOnNullableEnumWithSmartCast.kt", + "unexpectedBehaviour": false } ] }, @@ -259,6 +774,312 @@ "casesNumber": 25, "description": "\u0027When\u0027 with bound value and with different variants of expressions in the control structure body.", "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Annotated when statement", + "path": "compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum else", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt9929", + "path": "compiler/testData/diagnostics/tests/when/kt9929.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch false bypass", + "path": "compiler/testData/diagnostics/tests/when/BranchFalseBypass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check before", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBefore.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check else", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt4434", + "path": "compiler/testData/diagnostics/tests/when/kt4434.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Duplicated labels", + "path": "compiler/testData/diagnostics/tests/when/DuplicatedLabels.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10811", + "path": "compiler/testData/diagnostics/tests/when/kt10811.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum statement", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumStatement.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnum.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Comma in when condition without argument", + "path": "compiler/testData/diagnostics/tests/when/CommaInWhenConditionWithoutArgument.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive nullable", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch false bypass else", + "path": "compiler/testData/diagnostics/tests/when/BranchFalseBypassElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveInitialization.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheck.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check boolean", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBoolean.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum annotated", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumAnnotated.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else when statement", + "path": "compiler/testData/diagnostics/tests/when/NoElseWhenStatement.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10809", + "path": "compiler/testData/diagnostics/tests/when/kt10809.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10439", + "path": "compiler/testData/diagnostics/tests/when/kt10439.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive boolean nullable", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveBooleanNullable.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive no initialization", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveNoInitialization.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive return throw", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveReturnThrow.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive return", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveReturn.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive platform enum null", + "path": "compiler/testData/diagnostics/tests/when/ExhaustivePlatformEnumNull.kt", + "unexpectedBehaviour": false + } + ] + } + }, + "9": { + "pos": { + "2": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Annotated when statement", + "path": "compiler/testData/diagnostics/tests/when/AnnotatedWhenStatement.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else when statement", + "path": "compiler/testData/diagnostics/tests/when/NoElseWhenStatement.kt", + "unexpectedBehaviour": false + } + ], + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Duplicated labels", + "path": "compiler/testData/diagnostics/tests/when/DuplicatedLabels.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt9972", + "path": "compiler/testData/diagnostics/tests/when/kt9972.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10809", + "path": "compiler/testData/diagnostics/tests/when/kt10809.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10439", + "path": "compiler/testData/diagnostics/tests/when/kt10439.kt", + "unexpectedBehaviour": false + } + ] + }, + "neg": { + "2": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning null", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningNull.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else expected unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseExpectedUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarning.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned coercion to unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedCoercionToUnit.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning for sealed class", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned from lambda expected int", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedFromLambdaExpectedInt.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive with nullability check", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWithNullabilityCheck.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else no expected type", + "path": "compiler/testData/diagnostics/tests/when/NoElseNoExpectedType.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned non unit", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedNonUnit.kt", + "unexpectedBehaviour": false } ] } diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/determining-function-applicability-for-a-specific-call/description/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/determining-function-applicability-for-a-specific-call/description/testsMap.json new file mode 100644 index 00000000000..4550cdc74e0 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/determining-function-applicability-for-a-specific-call/description/testsMap.json @@ -0,0 +1,46 @@ +{ + "3": { + "neg": { + "3": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When and lambda with expected type", + "path": "compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "No else returned from lambda expected int", + "path": "compiler/testData/diagnostics/tests/when/NoElseReturnedFromLambdaExpectedInt.kt", + "unexpectedBehaviour": false + } + ] + }, + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10439", + "path": "compiler/testData/diagnostics/tests/when/kt10439.kt", + "unexpectedBehaviour": false + } + ] + } + }, + "1": { + "neg": { + "3": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When with nothing and lambdas", + "path": "compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/determining-function-applicability-for-a-specific-call/rationale/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/determining-function-applicability-for-a-specific-call/rationale/testsMap.json new file mode 100644 index 00000000000..598921b3b6b --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/overload-resolution/determining-function-applicability-for-a-specific-call/rationale/testsMap.json @@ -0,0 +1,15 @@ +{ + "1": { + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10439", + "path": "compiler/testData/diagnostics/tests/when/kt10439.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-inference/local-type-inference/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/type-inference/local-type-inference/testsMap.json new file mode 100644 index 00000000000..e0fbaa5ed80 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/type-inference/local-type-inference/testsMap.json @@ -0,0 +1,53 @@ +{ + "2": { + "neg": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When and lambda with expected type", + "path": "compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt", + "unexpectedBehaviour": false + } + ] + }, + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10811", + "path": "compiler/testData/diagnostics/tests/when/kt10811.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10809", + "path": "compiler/testData/diagnostics/tests/when/kt10809.kt", + "unexpectedBehaviour": false + } + ] + } + }, + "8": { + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10811", + "path": "compiler/testData/diagnostics/tests/when/kt10811.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10809", + "path": "compiler/testData/diagnostics/tests/when/kt10809.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-types/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-types/testsMap.json new file mode 100644 index 00000000000..16c2f928309 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/type-inference/smart-casts/smart-cast-types/testsMap.json @@ -0,0 +1,130 @@ +{ + "9": { + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch false bypass", + "path": "compiler/testData/diagnostics/tests/when/BranchFalseBypass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check before", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBefore.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check else", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch false bypass else", + "path": "compiler/testData/diagnostics/tests/when/BranchFalseBypassElse.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheck.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Exhaustive with nullability check boolean", + "path": "compiler/testData/diagnostics/tests/when/ExhaustiveWithNullabilityCheckBoolean.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10809", + "path": "compiler/testData/diagnostics/tests/when/kt10809.kt", + "unexpectedBehaviour": false + } + ], + "8": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch false bypass", + "path": "compiler/testData/diagnostics/tests/when/BranchFalseBypass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch false bypass else", + "path": "compiler/testData/diagnostics/tests/when/BranchFalseBypassElse.kt", + "unexpectedBehaviour": false + } + ] + }, + "neg": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When type disjunctions", + "path": "compiler/testData/diagnostics/tests/when/WhenTypeDisjunctions.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch bypass val", + "path": "compiler/testData/diagnostics/tests/when/BranchBypassVal.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive warning for sealed class", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWarningForSealedClass.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch bypass var", + "path": "compiler/testData/diagnostics/tests/when/BranchBypassVar.kt", + "unexpectedBehaviour": false + }, + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Non exhaustive with nullability check", + "path": "compiler/testData/diagnostics/tests/when/NonExhaustiveWithNullabilityCheck.kt", + "unexpectedBehaviour": false + } + ], + "6": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch bypass val", + "path": "compiler/testData/diagnostics/tests/when/BranchBypassVal.kt", + "unexpectedBehaviour": false + } + ], + "8": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Branch bypass var", + "path": "compiler/testData/diagnostics/tests/when/BranchBypassVar.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/testsMap.json index cc4b8c0d996..5095388485b 100644 --- a/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/testsMap.json +++ b/compiler/tests-spec/testData/diagnostics/linked/type-system/introduction-1/testsMap.json @@ -62,5 +62,18 @@ } ] } + }, + "5": { + "pos": { + "2": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt9929", + "path": "compiler/testData/diagnostics/tests/when/kt9929.kt", + "unexpectedBehaviour": false + } + ] + } } } \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-for-nullable-types/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-for-nullable-types/testsMap.json new file mode 100644 index 00000000000..0495e7a37b0 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-for-nullable-types/testsMap.json @@ -0,0 +1,24 @@ +{ + "4": { + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10811", + "path": "compiler/testData/diagnostics/tests/when/kt10811.kt", + "unexpectedBehaviour": false + } + ], + "2": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10811", + "path": "compiler/testData/diagnostics/tests/when/kt10811.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-rules/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-rules/testsMap.json new file mode 100644 index 00000000000..cf85cc8d057 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/type-system/subtyping/subtyping-rules/testsMap.json @@ -0,0 +1,26 @@ +{ + "2": { + "neg": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "When and lambda with expected type", + "path": "compiler/testData/diagnostics/tests/when/whenAndLambdaWithExpectedType.kt", + "unexpectedBehaviour": false + } + ] + }, + "pos": { + "3": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10811", + "path": "compiler/testData/diagnostics/tests/when/kt10811.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/linked/type-system/type-kinds/type-parameters/testsMap.json b/compiler/tests-spec/testData/diagnostics/linked/type-system/type-kinds/type-parameters/testsMap.json new file mode 100644 index 00000000000..503b2b23d53 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/linked/type-system/type-kinds/type-parameters/testsMap.json @@ -0,0 +1,15 @@ +{ + "4": { + "pos": { + "1": [ + { + "specVersion": "0.1-155", + "casesNumber": 0, + "description": "Kt10809", + "path": "compiler/testData/diagnostics/tests/when/kt10809.kt", + "unexpectedBehaviour": false + } + ] + } + } +} \ No newline at end of file diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/codegen/AbstractBlackBoxCodegenTestSpec.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/codegen/AbstractBlackBoxCodegenTestSpec.kt index cf2d4fa95d7..d9e6ae8b506 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/codegen/AbstractBlackBoxCodegenTestSpec.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/codegen/AbstractBlackBoxCodegenTestSpec.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.spec.codegen import com.intellij.openapi.util.io.FileUtil import org.jetbrains.kotlin.TestExceptionsComparator import org.jetbrains.kotlin.codegen.AbstractBlackBoxCodegenTest -import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH +import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.SPEC_TESTDATA_PATH import org.jetbrains.kotlin.spec.utils.models.AbstractSpecTest import org.jetbrains.kotlin.spec.utils.parsers.CommonParser import org.jetbrains.kotlin.spec.utils.parsers.CommonPatterns.packagePattern @@ -19,7 +19,7 @@ import java.io.* abstract class AbstractBlackBoxCodegenTestSpec : AbstractBlackBoxCodegenTest() { companion object { - private const val CODEGEN_BOX_TESTDATA_PATH = "$TESTDATA_PATH/codegen/box" + private const val CODEGEN_BOX_TESTDATA_PATH = "$SPEC_TESTDATA_PATH/codegen/box" private const val HELPERS_PATH = "$CODEGEN_BOX_TESTDATA_PATH/helpers" private const val HELPERS_PACKAGE_VARIABLE = "" } diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt index ffb9239f04e..4646b2ab60f 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/consistency/SpecTestsConsistencyTest.kt @@ -37,11 +37,11 @@ class SpecTestsConsistencyTest : TestCase() { TestArea.values().forEach { testArea -> val testDataPath = - "${GeneralConfiguration.TESTDATA_PATH}/${testArea.testDataPath}/${SpecTestLinkedType.LINKED.testDataPath}" + "${GeneralConfiguration.SPEC_TESTDATA_PATH}/${testArea.testDataPath}/${SpecTestLinkedType.LINKED.testDataPath}" testFiles += File(testDataPath).let { testsDir -> testsDir.walkTopDown().filter { it.extension == "kt" }.map { - arrayOf(it.relativeTo(File(GeneralConfiguration.TESTDATA_PATH)).path.replace("/", "$")) + arrayOf(it.relativeTo(File(GeneralConfiguration.SPEC_TESTDATA_PATH)).path.replace("/", "$")) }.toList() } } @@ -52,7 +52,7 @@ class SpecTestsConsistencyTest : TestCase() { @Test fun doTest() { - val file = File("${GeneralConfiguration.TESTDATA_PATH}/${testFilePath.replace("$", "/")}") + val file = File("${GeneralConfiguration.SPEC_TESTDATA_PATH}/${testFilePath.replace("$", "/")}") val specSentences = specSentencesStorage.getLatest() ?: return val test = parseLinkedSpecTest(file.canonicalPath, mapOf("main" to file.readText())) val sectionsPath = setOf(*test.place.sections.toTypedArray(), test.place.paragraphNumber).joinToString() diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/GeneralConfiguration.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/GeneralConfiguration.kt index 0a1459f5a4b..efc80742bc4 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/GeneralConfiguration.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/GeneralConfiguration.kt @@ -6,7 +6,8 @@ package org.jetbrains.kotlin.spec.utils object GeneralConfiguration { - const val MODULE_PATH = "compiler/tests-spec" - const val TESTDATA_PATH = "$MODULE_PATH/testData" - const val TEST_PATH = "$MODULE_PATH/tests" + const val TESTDATA_PATH = "compiler/testData" + const val SPEC_MODULE_PATH = "compiler/tests-spec" + const val SPEC_TESTDATA_PATH = "$SPEC_MODULE_PATH/testData" + const val SPEC_TEST_PATH = "$SPEC_MODULE_PATH/tests" } diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapGenerator.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapGenerator.kt index f109177409b..3c68841ff92 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapGenerator.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsJsonMapGenerator.kt @@ -10,13 +10,17 @@ import com.google.gson.JsonArray import com.google.gson.JsonElement import com.google.gson.JsonObject import org.jetbrains.kotlin.spec.utils.models.LinkedSpecTest +import org.jetbrains.kotlin.spec.utils.models.LinkedSpecTest.Companion.getInstanceForImplementationTest import org.jetbrains.kotlin.spec.utils.models.SpecPlace import org.jetbrains.kotlin.spec.utils.parsers.CommonParser +import org.jetbrains.kotlin.spec.utils.parsers.ImplementationTestPatterns import java.io.File object TestsJsonMapGenerator { private const val LINKED_TESTS_PATH = "linked" - private const val TESTS_MAP_FILENAME = "testsMap.json" + const val TESTS_MAP_FILENAME = "testsMap.json" + + private val testsMap = JsonObject() private inline fun JsonObject.getOrCreate(key: String): T { if (!has(key)) { @@ -46,11 +50,9 @@ object TestsJsonMapGenerator { ) } - fun buildTestsMapPerSection() { - val testsMap = JsonObject() - + private fun collectInfoFromSpecTests() { TestArea.values().forEach { testArea -> - File("${GeneralConfiguration.TESTDATA_PATH}/${testArea.testDataPath}/$LINKED_TESTS_PATH").walkTopDown() + File("${GeneralConfiguration.SPEC_TESTDATA_PATH}/${testArea.testDataPath}/$LINKED_TESTS_PATH").walkTopDown() .forEach testFiles@{ file -> if (!file.isFile || file.extension != "kt") return@testFiles @@ -68,11 +70,57 @@ object TestsJsonMapGenerator { } } } + } + + private fun collectInfoFromImplementationTests() { + TestArea.values().forEach { testArea -> + File("${GeneralConfiguration.TESTDATA_PATH}/${testArea.testDataPath}").walkTopDown() + .forEach testFiles@{ file -> + if (!file.isFile || file.extension != "kt") return@testFiles + + val matcher = ImplementationTestPatterns.testInfoPattern.matcher(file.readText()) + + if (!matcher.find()) return@testFiles + + val specVersion = matcher.group("specVersion") + val testType = TestType.fromValue(matcher.group("testType"))!! + val testSpecSentenceList = matcher.group("testSpecSentenceList") + val specSentenceListMatcher = ImplementationTestPatterns.relevantSpecSentencesPattern.matcher(testSpecSentenceList) + val specPlaces = mutableSetOf() + + while (specSentenceListMatcher.find()) { + specPlaces.add( + SpecPlace( + sections = specSentenceListMatcher.group("specSections").split(Regex(""",\s*""")), + paragraphNumber = specSentenceListMatcher.group("specParagraph").toInt(), + sentenceNumber = specSentenceListMatcher.group("specSentence").toInt() + ) + ) + } + + specPlaces.forEach { specPlace -> + testsMap.getOrCreateSpecTestObject(specPlace, testArea, testType).add( + getTestInfo( + getInstanceForImplementationTest(specVersion, testArea, testType, specPlace, file.nameWithoutExtension), + file + ) + ) + } + } + } + } + + fun buildTestsMapPerSection() { + collectInfoFromSpecTests() + collectInfoFromImplementationTests() val gson = GsonBuilder().setPrettyPrinting().create() testsMap.keySet().forEach { testPath -> - File("${GeneralConfiguration.TESTDATA_PATH}/$testPath/$TESTS_MAP_FILENAME").writeText(gson.toJson(testsMap.get(testPath))) + val testMapFolder = "${GeneralConfiguration.SPEC_TESTDATA_PATH}/$testPath" + + File(testMapFolder).mkdirs() + File("$testMapFolder/$TESTS_MAP_FILENAME").writeText(gson.toJson(testsMap.get(testPath))) } } } diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsStatisticCollector.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsStatisticCollector.kt index b16faef2be4..8a2d296cf98 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsStatisticCollector.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/TestsStatisticCollector.kt @@ -5,7 +5,7 @@ package org.jetbrains.kotlin.spec.utils -import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH +import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.SPEC_TESTDATA_PATH import org.jetbrains.kotlin.spec.utils.models.AbstractSpecTest import org.jetbrains.kotlin.spec.utils.parsers.CommonParser import java.io.File @@ -43,7 +43,7 @@ object TestsStatisticCollector { val statistic = mutableMapOf() for (specTestArea in TestArea.values()) { - val specTestsPath = "$TESTDATA_PATH/${specTestArea.name.toLowerCase().replace("_", "/")}/${testLinkedType.testDataPath}" + val specTestsPath = "$SPEC_TESTDATA_PATH/${specTestArea.name.toLowerCase().replace("_", "/")}/${testLinkedType.testDataPath}" statistic[specTestArea] = SpecTestsStatElement(SpecTestsStatElementType.AREA) diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/generators/templates/FeatureInteractionTestDataGenerator.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/generators/templates/FeatureInteractionTestDataGenerator.kt index 3fd8785596d..926f505b039 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/generators/templates/FeatureInteractionTestDataGenerator.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/generators/templates/FeatureInteractionTestDataGenerator.kt @@ -5,7 +5,7 @@ package org.jetbrains.kotlin.spec.utils.generators.templates -import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH +import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.SPEC_TESTDATA_PATH import java.io.File import java.util.regex.Pattern @@ -78,8 +78,8 @@ class FeatureInteractionTestDataGenerator(private val configuration: GenerationS fun generate() { var testNumber = 1 - val testsPartPath = "$TESTDATA_PATH/${configuration.getTestsPartPath()}" - val layoutTemplate = File("$TESTDATA_PATH/${configuration.getLayoutPath()}").readText() + val testsPartPath = "$SPEC_TESTDATA_PATH/${configuration.getTestsPartPath()}" + val layoutTemplate = File("$SPEC_TESTDATA_PATH/${configuration.getLayoutPath()}").readText() File(testsPartPath).parentFile.mkdirs() diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/generators/templates/FeatureTemplatesConfig.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/generators/templates/FeatureTemplatesConfig.kt index 7f254e88d0b..7fc20798e8e 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/generators/templates/FeatureTemplatesConfig.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/generators/templates/FeatureTemplatesConfig.kt @@ -5,7 +5,7 @@ package org.jetbrains.kotlin.spec.utils.generators.templates -import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH +import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.SPEC_TESTDATA_PATH import org.jetbrains.kotlin.spec.utils.TestArea import java.io.File @@ -24,7 +24,7 @@ class FeatureTemplatesConfig( var currentTemplatesIterator = getTemplatesIterator() private fun getTemplatesPath(testArea: TestArea) = buildString { - append(TESTDATA_PATH) + append(SPEC_TESTDATA_PATH) append("/${testArea.testDataPath}") append("/${FeatureInteractionTestDataGenerator.TEMPLATES_PATH}") append("/$templatesPath") diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/models/LinkedSpecTest.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/models/LinkedSpecTest.kt index 314b05e299d..caed1867405 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/models/LinkedSpecTest.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/models/LinkedSpecTest.kt @@ -50,6 +50,26 @@ class LinkedSpecTest( helpers: Set?, exception: TestsExceptionType? ) : AbstractSpecTest(testArea, testType, place.sections, testNumber, description, cases, unexpectedBehavior, issues, helpers, exception) { + companion object { + fun getInstanceForImplementationTest( + specVersion: String, + testArea: TestArea, + testType: TestType, + specPlace: SpecPlace, + filename: String + ): LinkedSpecTest { + val description = filename[0].toUpperCase() + + filename.substring(1).replace(Regex("""([A-Z])"""), " $1").toLowerCase() + + return LinkedSpecTest( + specVersion, testArea, testType, specPlace, + null, 0, description, + SpecTestCasesSet(mutableMapOf(), mutableMapOf(), mutableMapOf()), + unexpectedBehavior = false, unspecifiedBehavior = false, issues = setOf(), helpers = null, exception = null + ) + } + } + override fun checkPathConsistency(pathMatcher: Matcher) = testArea == TestArea.valueOf(pathMatcher.group("testArea").withUnderscores()) && testType == TestType.fromValue(pathMatcher.group("testType"))!! diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/parsers/Patterns.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/parsers/Patterns.kt index 6f4124fa876..e022f0305f9 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/parsers/Patterns.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/parsers/Patterns.kt @@ -65,7 +65,7 @@ object NotLinkedSpecTestPatterns : BasePatterns { } object LinkedSpecTestPatterns : BasePatterns { - const val FILENAME_REGEX = """(?$INTEGER_REGEX)\.(?$INTEGER_REGEX)\.kt""" + private const val FILENAME_REGEX = """(?$INTEGER_REGEX)\.(?$INTEGER_REGEX)\.kt""" override val pathPartRegex = """${SpecTestLinkedType.LINKED.testDataPath}$ps$sectionsInPathRegex${ps}p-(?$INTEGER_REGEX)""" @@ -98,3 +98,10 @@ object TestCasePatterns { val testCaseInfoPattern: Pattern = Pattern.compile("(?:$testCaseInfoSingleLineRegex)|(?:$testCaseInfoMultilineRegex)") val testCaseNumberPattern: Pattern = Pattern.compile("""([1-9]\d*)(,\s*[1-9]\d*)*""") } + +object ImplementationTestPatterns { + val testInfoPattern: Pattern = + Pattern.compile(MULTILINE_COMMENT_REGEX.format("""\*\s+RELEVANT SPEC SENTENCES \(spec version: (?\d+\.[0-9]\d*\-[0-9]\d*), test type: (?pos|neg)\):(?(\n\s+\*\s+-\s+.*?)+)""")) + val relevantSpecSentencesPattern: Pattern = + Pattern.compile("""\n\s+\*\s+-\s+(?.*?) -> paragraph (?[1-9]\d*) -> sentence (?[1-9]\d*)""") +} diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/spec/HtmlSpecLoader.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/spec/HtmlSpecLoader.kt index ff9dd40b6d8..162d4ddcf02 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/spec/HtmlSpecLoader.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/spec/HtmlSpecLoader.kt @@ -18,7 +18,7 @@ object HtmlSpecLoader { private const val SPEC_DOCS_TC_CONFIGURATION_ID = "Kotlin_Spec_DocsMaster" private const val TC_URL = "https://teamcity.jetbrains.com" private const val TC_PATH_PREFIX = "guestAuth/app/rest/builds" - private const val HTML_SPEC_PATH = "/web/kotlin-spec.html" + private const val HTML_SPEC_PATH = "/html/kotlin-spec.html" private const val STABLE_BRANCH = "master" private fun loadRawHtmlSpec(specVersion: String, buildNumber: String): String { diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateSpecTests.kt b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateSpecTests.kt index 438a37cc177..864cbf52f83 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateSpecTests.kt +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/utils/tasks/GenerateSpecTests.kt @@ -9,20 +9,45 @@ import org.jetbrains.kotlin.generators.tests.generator.testGroup import org.jetbrains.kotlin.spec.checkers.AbstractDiagnosticsTestSpec import org.jetbrains.kotlin.spec.codegen.AbstractBlackBoxCodegenTestSpec import org.jetbrains.kotlin.spec.parsing.AbstractParsingTestSpec -import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TESTDATA_PATH -import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.TEST_PATH +import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.SPEC_TESTDATA_PATH +import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.SPEC_TEST_PATH import org.jetbrains.kotlin.spec.utils.TestsJsonMapGenerator +import org.jetbrains.kotlin.spec.utils.TestsJsonMapGenerator.TESTS_MAP_FILENAME +import java.io.File +import java.nio.file.Files + +fun detectDirsWithTestsMapFileOnly(dirName: String): List { + val excludedDirs = mutableListOf() + + File("$SPEC_TESTDATA_PATH/$dirName").walkTopDown().forEach { file -> + val listFiles = Files.walk(file.toPath()).filter(Files::isRegularFile) + + if (file.isDirectory && listFiles?.allMatch { it.endsWith(TESTS_MAP_FILENAME) } == true) { + val relativePath = file.relativeTo(File("$SPEC_TESTDATA_PATH/$dirName")).path + + if (!excludedDirs.any { relativePath.startsWith(it) }) { + excludedDirs.add(relativePath) + } + } + } + + return excludedDirs +} fun generateTests() { - testGroup(TEST_PATH, TESTDATA_PATH) { + testGroup(SPEC_TEST_PATH, SPEC_TESTDATA_PATH) { testClass { - model("diagnostics", excludeDirs = listOf("helpers")) + model("diagnostics", excludeDirs = listOf("helpers") + detectDirsWithTestsMapFileOnly("diagnostics")) } testClass { - model("psi", testMethod = "doParsingTest", excludeDirs = listOf("helpers", "templates")) + model( + relativeRootPath = "psi", + testMethod = "doParsingTest", + excludeDirs = listOf("helpers", "templates") + detectDirsWithTestsMapFileOnly("psi") + ) } testClass { - model("codegen/box", excludeDirs = listOf("helpers", "templates")) + model("codegen/box", excludeDirs = listOf("helpers", "templates") + detectDirsWithTestsMapFileOnly("codegen/box")) } } }