From 85949b387e895bd4bd2cb1dd832df03e5d617745 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Mon, 29 Mar 2021 12:04:32 +0300 Subject: [PATCH] [Test] Explicitly enable UNUSED_* diagnostics in tests which are not belong to contolFlowAnalysis suite --- .../diagnostics/tests/SafeCallNonNullReceiverReturnNull.kt | 2 +- compiler/testData/diagnostics/tests/UnusedInDestructuring.kt | 2 ++ compiler/testData/diagnostics/tests/UnusedVariables.kt | 2 ++ .../tests/annotations/rendering/unusedValue.fir.kt | 2 +- .../diagnostics/tests/annotations/rendering/unusedValue.kt | 2 +- .../tests/callableReference/bound/controlFlow.fir.kt | 2 ++ .../diagnostics/tests/callableReference/bound/controlFlow.kt | 2 ++ .../diagnostics/tests/callableReference/unused.fir.kt | 3 ++- .../testData/diagnostics/tests/callableReference/unused.kt | 3 ++- .../anonymousFunUnusedLastExpressionInBlock.fir.kt | 2 ++ .../anonymousFunUnusedLastExpressionInBlock.kt | 2 ++ .../return/LocalReturnUnitWithBodyExpression.fir.kt | 4 +++- .../return/LocalReturnUnitWithBodyExpression.kt | 4 +++- .../diagnostics/tests/functionLiterals/unusedLiteral.kt | 4 +++- .../functionLiterals/unusedLiteralInsideUnitLiteral.fir.kt | 2 ++ .../tests/functionLiterals/unusedLiteralInsideUnitLiteral.kt | 2 ++ compiler/testData/diagnostics/tests/script/ComplexScript.kts | 2 ++ .../tests/typealias/unusedTypeAliasParameter.fir.kt | 1 + .../diagnostics/tests/typealias/unusedTypeAliasParameter.kt | 1 + .../when/withSubjectVariable/unusedWhenSubjectVariable.kt | 3 ++- .../testsWithStdLib/CallToMainRedeclaredInMultiFile.fir.kt | 3 ++- .../testsWithStdLib/CallToMainRedeclaredInMultiFile.kt | 3 ++- 22 files changed, 42 insertions(+), 11 deletions(-) diff --git a/compiler/testData/diagnostics/tests/SafeCallNonNullReceiverReturnNull.kt b/compiler/testData/diagnostics/tests/SafeCallNonNullReceiverReturnNull.kt index eccc9ecef1c..e105ae0a135 100644 --- a/compiler/testData/diagnostics/tests/SafeCallNonNullReceiverReturnNull.kt +++ b/compiler/testData/diagnostics/tests/SafeCallNonNullReceiverReturnNull.kt @@ -3,5 +3,5 @@ fun Int.gg() = null fun ff() { val a: Int = 1 - val b: Int = a?.gg() + val b: Int = a?.gg() } diff --git a/compiler/testData/diagnostics/tests/UnusedInDestructuring.kt b/compiler/testData/diagnostics/tests/UnusedInDestructuring.kt index 5b5ff5b32b3..720d3b1eef3 100644 --- a/compiler/testData/diagnostics/tests/UnusedInDestructuring.kt +++ b/compiler/testData/diagnostics/tests/UnusedInDestructuring.kt @@ -1,3 +1,5 @@ +// !DIAGNOSICS: +UNUSED_VARIABLE + data class D(val x: Int, val y: Int, val z: Int) fun foo(): Int { val (x, y, z) = D(1, 2, 3) diff --git a/compiler/testData/diagnostics/tests/UnusedVariables.kt b/compiler/testData/diagnostics/tests/UnusedVariables.kt index d10f86b26c2..bbfaeee655c 100644 --- a/compiler/testData/diagnostics/tests/UnusedVariables.kt +++ b/compiler/testData/diagnostics/tests/UnusedVariables.kt @@ -1,3 +1,5 @@ +// !DIAGNOSICS: +UNUSED_VALUE, +UNUSED_CHANGED_VALUE, +UNUSED_PARAMETER, UNUSED_VARIABLE + package unused_variables fun testSimpleCases() { diff --git a/compiler/testData/diagnostics/tests/annotations/rendering/unusedValue.fir.kt b/compiler/testData/diagnostics/tests/annotations/rendering/unusedValue.fir.kt index 42e57965221..0108035af89 100644 --- a/compiler/testData/diagnostics/tests/annotations/rendering/unusedValue.fir.kt +++ b/compiler/testData/diagnostics/tests/annotations/rendering/unusedValue.fir.kt @@ -1,5 +1,5 @@ // !RENDER_DIAGNOSTICS_MESSAGES -// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE +// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE +UNUSED_VALUE @Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.LOCAL_VARIABLE) annotation class A diff --git a/compiler/testData/diagnostics/tests/annotations/rendering/unusedValue.kt b/compiler/testData/diagnostics/tests/annotations/rendering/unusedValue.kt index a78442158f8..86b44f08cc7 100644 --- a/compiler/testData/diagnostics/tests/annotations/rendering/unusedValue.kt +++ b/compiler/testData/diagnostics/tests/annotations/rendering/unusedValue.kt @@ -1,5 +1,5 @@ // !RENDER_DIAGNOSTICS_MESSAGES -// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE +// !DIAGNOSTICS: -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE +UNUSED_VALUE @Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.TYPE, AnnotationTarget.LOCAL_VARIABLE) annotation class A diff --git a/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.fir.kt b/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.fir.kt index a7879898c7c..e5ef472e29b 100644 --- a/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.fir.kt @@ -1,3 +1,5 @@ +// !DIAGNOSICS: +UNUSED_EXPRESSION + fun unusedExpression(s: String) { s::hashCode s::class diff --git a/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.kt b/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.kt index 6771eeb1573..66c2a1367fa 100644 --- a/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.kt +++ b/compiler/testData/diagnostics/tests/callableReference/bound/controlFlow.kt @@ -1,3 +1,5 @@ +// !DIAGNOSICS: +UNUSED_EXPRESSION + fun unusedExpression(s: String) { s::hashCode s::class diff --git a/compiler/testData/diagnostics/tests/callableReference/unused.fir.kt b/compiler/testData/diagnostics/tests/callableReference/unused.fir.kt index b6327ef551f..6372d175da6 100644 --- a/compiler/testData/diagnostics/tests/callableReference/unused.fir.kt +++ b/compiler/testData/diagnostics/tests/callableReference/unused.fir.kt @@ -1,3 +1,4 @@ +// !DIAGNOSICS: +UNUSED_EXPRESSION fun foo() { } @@ -20,4 +21,4 @@ fun test() { A::B A::foo A::bar -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/callableReference/unused.kt b/compiler/testData/diagnostics/tests/callableReference/unused.kt index 3ed2441492a..3fd96ee645d 100644 --- a/compiler/testData/diagnostics/tests/callableReference/unused.kt +++ b/compiler/testData/diagnostics/tests/callableReference/unused.kt @@ -1,3 +1,4 @@ +// !DIAGNOSICS: +UNUSED_EXPRESSION fun foo() { } @@ -20,4 +21,4 @@ fun test() { A::B A::foo A::bar -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/anonymousFunUnusedLastExpressionInBlock.fir.kt b/compiler/testData/diagnostics/tests/declarationChecks/anonymousFunUnusedLastExpressionInBlock.fir.kt index e8ba7c71cb2..5ed91d1bbbe 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/anonymousFunUnusedLastExpressionInBlock.fir.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/anonymousFunUnusedLastExpressionInBlock.fir.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: +UNUSED_EXPRESSION + fun unusedExpressions() { if (1 == 1) fun(): Int {return 1} diff --git a/compiler/testData/diagnostics/tests/declarationChecks/anonymousFunUnusedLastExpressionInBlock.kt b/compiler/testData/diagnostics/tests/declarationChecks/anonymousFunUnusedLastExpressionInBlock.kt index 3189c97ccf6..715360c2bc2 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/anonymousFunUnusedLastExpressionInBlock.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/anonymousFunUnusedLastExpressionInBlock.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: +UNUSED_EXPRESSION + fun unusedExpressions() { if (1 == 1) fun(): Int {return 1} diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnitWithBodyExpression.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnitWithBodyExpression.fir.kt index bd67e82f22d..06c9f6dbd84 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnitWithBodyExpression.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnitWithBodyExpression.fir.kt @@ -1,7 +1,9 @@ +// !DIAGNOSTICS: +UNUSED_EXPRESSION + val flag = true // type of lambda was checked by txt val a = b@ { // () -> Unit if (flag) return@b else 54 -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnitWithBodyExpression.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnitWithBodyExpression.kt index 2c4627edc27..bad4ac9f644 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnitWithBodyExpression.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/LocalReturnUnitWithBodyExpression.kt @@ -1,7 +1,9 @@ +// !DIAGNOSTICS: +UNUSED_EXPRESSION + val flag = true // type of lambda was checked by txt val a = b@ { // () -> Unit if (flag) return@b else 54 -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt b/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt index 05c2d1eda9d..95d2636da95 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteral.kt @@ -1,3 +1,5 @@ +// !DIAGNOSICS: +UNUSED_LAMBDA_EXPRESSION, +UNUSED_VARIABLE + fun unusedLiteral(){ { -> val i = 1 @@ -9,4 +11,4 @@ fun unusedLiteralInDoWhile(){ do{ -> val i = 1 } while(false) -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteralInsideUnitLiteral.fir.kt b/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteralInsideUnitLiteral.fir.kt index 48149e6bb47..61f6aa580ee 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteralInsideUnitLiteral.fir.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteralInsideUnitLiteral.fir.kt @@ -1,3 +1,5 @@ +// !DIAGNOSICS: +UNUSED_LAMBDA_EXPRESSION + fun main() { "".run { {} diff --git a/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteralInsideUnitLiteral.kt b/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteralInsideUnitLiteral.kt index da0361179e8..f3c152843ec 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteralInsideUnitLiteral.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/unusedLiteralInsideUnitLiteral.kt @@ -1,3 +1,5 @@ +// !DIAGNOSICS: +UNUSED_LAMBDA_EXPRESSION + fun main() { "".run { {} diff --git a/compiler/testData/diagnostics/tests/script/ComplexScript.kts b/compiler/testData/diagnostics/tests/script/ComplexScript.kts index e72eb620293..bc9bce6e138 100644 --- a/compiler/testData/diagnostics/tests/script/ComplexScript.kts +++ b/compiler/testData/diagnostics/tests/script/ComplexScript.kts @@ -1,3 +1,5 @@ +// !DIAGNOSICS: +UNUSED_PARAMETER + fun foo(x: Int) = 1 val y = 2 diff --git a/compiler/testData/diagnostics/tests/typealias/unusedTypeAliasParameter.fir.kt b/compiler/testData/diagnostics/tests/typealias/unusedTypeAliasParameter.fir.kt index ae5caa6933a..578801571ad 100644 --- a/compiler/testData/diagnostics/tests/typealias/unusedTypeAliasParameter.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/unusedTypeAliasParameter.fir.kt @@ -1,2 +1,3 @@ +// !DIAGNOSICS: +UNUSED_TYPEALIAS_PARAMETER typealias Test = List typealias Test2 = Test diff --git a/compiler/testData/diagnostics/tests/typealias/unusedTypeAliasParameter.kt b/compiler/testData/diagnostics/tests/typealias/unusedTypeAliasParameter.kt index 2d11992bd01..3f05904628c 100644 --- a/compiler/testData/diagnostics/tests/typealias/unusedTypeAliasParameter.kt +++ b/compiler/testData/diagnostics/tests/typealias/unusedTypeAliasParameter.kt @@ -1,2 +1,3 @@ +// !DIAGNOSICS: +UNUSED_TYPEALIAS_PARAMETER typealias TestX> = List typealias Test2X> = Test diff --git a/compiler/testData/diagnostics/tests/when/withSubjectVariable/unusedWhenSubjectVariable.kt b/compiler/testData/diagnostics/tests/when/withSubjectVariable/unusedWhenSubjectVariable.kt index 80a72a95fdc..615bd63a49c 100644 --- a/compiler/testData/diagnostics/tests/when/withSubjectVariable/unusedWhenSubjectVariable.kt +++ b/compiler/testData/diagnostics/tests/when/withSubjectVariable/unusedWhenSubjectVariable.kt @@ -1,8 +1,9 @@ // !LANGUAGE: +VariableDeclarationInWhenSubject +// !DIAGNOSICS: +UNUSED_VARIABLE fun foo(): Any = 42 fun test() { when (val x = foo()) { } -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/CallToMainRedeclaredInMultiFile.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/CallToMainRedeclaredInMultiFile.fir.kt index fa42313fa06..fd9991d2390 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/CallToMainRedeclaredInMultiFile.fir.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/CallToMainRedeclaredInMultiFile.fir.kt @@ -1,4 +1,5 @@ // !LANGUAGE: +WarningOnMainUnusedParameter +// !DIAGNOSTICS: +UNUSED_PARAMETER // FILE: a.kt fun main(args: Array) {} @@ -7,4 +8,4 @@ fun main(args: Array) {} fun main(args: Array) {} // FILE: c.kt -fun foo() { main(arrayOf("a", "b")) } \ No newline at end of file +fun foo() { main(arrayOf("a", "b")) } diff --git a/compiler/testData/diagnostics/testsWithStdLib/CallToMainRedeclaredInMultiFile.kt b/compiler/testData/diagnostics/testsWithStdLib/CallToMainRedeclaredInMultiFile.kt index 80f6f12ac34..d6cba189373 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/CallToMainRedeclaredInMultiFile.kt +++ b/compiler/testData/diagnostics/testsWithStdLib/CallToMainRedeclaredInMultiFile.kt @@ -1,4 +1,5 @@ // !LANGUAGE: +WarningOnMainUnusedParameter +// !DIAGNOSTICS: +UNUSED_PARAMETER // FILE: a.kt fun main(args: Array) {} @@ -7,4 +8,4 @@ fun main(args: Array) {} fun main(args: Array) {} // FILE: c.kt -fun foo() { main(arrayOf("a", "b")) } \ No newline at end of file +fun foo() { main(arrayOf("a", "b")) }