[Test] Explicitly enable UNUSED_* diagnostics in tests which are not belong to contolFlowAnalysis suite

This commit is contained in:
Dmitriy Novozhilov
2021-03-29 12:04:32 +03:00
committed by TeamCityServer
parent a9ff030c73
commit 85949b387e
22 changed files with 42 additions and 11 deletions
@@ -3,5 +3,5 @@ fun Int.gg() = null
fun ff() {
val a: Int = 1
val <!UNUSED_VARIABLE!>b<!>: Int = <!TYPE_MISMATCH!>a<!UNNECESSARY_SAFE_CALL!>?.<!>gg()<!>
val b: Int = <!TYPE_MISMATCH!>a<!UNNECESSARY_SAFE_CALL!>?.<!>gg()<!>
}
@@ -1,3 +1,5 @@
// !DIAGNOSICS: +UNUSED_VARIABLE
data class D(val x: Int, val y: Int, val z: Int)
fun foo(): Int {
val (<!UNUSED_VARIABLE!>x<!>, y, z) = D(1, 2, 3)
@@ -1,3 +1,5 @@
// !DIAGNOSICS: +UNUSED_VALUE, +UNUSED_CHANGED_VALUE, +UNUSED_PARAMETER, UNUSED_VARIABLE
package unused_variables
fun testSimpleCases() {
@@ -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
@@ -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
@@ -1,3 +1,5 @@
// !DIAGNOSICS: +UNUSED_EXPRESSION
fun unusedExpression(s: String) {
s::hashCode
s::class
@@ -1,3 +1,5 @@
// !DIAGNOSICS: +UNUSED_EXPRESSION
fun unusedExpression(s: String) {
<!UNUSED_EXPRESSION!>s::hashCode<!>
<!UNUSED_EXPRESSION!>s::class<!>
@@ -1,3 +1,4 @@
// !DIAGNOSICS: +UNUSED_EXPRESSION
fun foo() {
}
@@ -20,4 +21,4 @@ fun test() {
A::B
A::foo
A::bar
}
}
@@ -1,3 +1,4 @@
// !DIAGNOSICS: +UNUSED_EXPRESSION
fun foo() {
}
@@ -20,4 +21,4 @@ fun test() {
<!UNUSED_EXPRESSION!>A::B<!>
<!UNUSED_EXPRESSION!>A::foo<!>
<!UNUSED_EXPRESSION!>A::bar<!>
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: +UNUSED_EXPRESSION
fun unusedExpressions() {
if (1 == 1)
fun(): Int {return 1}
@@ -1,3 +1,5 @@
// !DIAGNOSTICS: +UNUSED_EXPRESSION
fun unusedExpressions() {
if (1 == 1)
<!UNUSED_EXPRESSION!>fun(): Int {return 1}<!>
@@ -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
}
}
@@ -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 <!UNUSED_EXPRESSION!>54<!>
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSICS: +UNUSED_LAMBDA_EXPRESSION, +UNUSED_VARIABLE
fun unusedLiteral(){
<!UNUSED_LAMBDA_EXPRESSION!>{ ->
val <!UNUSED_VARIABLE!>i<!> = 1
@@ -9,4 +11,4 @@ fun unusedLiteralInDoWhile(){
do<!UNUSED_LAMBDA_EXPRESSION!>{ ->
val <!UNUSED_VARIABLE!>i<!> = 1
}<!> while(false)
}
}
@@ -1,3 +1,5 @@
// !DIAGNOSICS: +UNUSED_LAMBDA_EXPRESSION
fun main() {
"".run {
{}
@@ -1,3 +1,5 @@
// !DIAGNOSICS: +UNUSED_LAMBDA_EXPRESSION
fun main() {
"".run {
<!UNUSED_LAMBDA_EXPRESSION!>{}<!>
@@ -1,3 +1,5 @@
// !DIAGNOSICS: +UNUSED_PARAMETER
fun foo(<!UNUSED_PARAMETER!>x<!>: Int) = 1
val y = 2
@@ -1,2 +1,3 @@
// !DIAGNOSICS: +UNUSED_TYPEALIAS_PARAMETER
typealias Test<T, X> = List<T>
typealias Test2<T, X> = Test<T, X>
@@ -1,2 +1,3 @@
// !DIAGNOSICS: +UNUSED_TYPEALIAS_PARAMETER
typealias Test<T, <!UNUSED_TYPEALIAS_PARAMETER!>X<!>> = List<T>
typealias Test2<T, <!UNUSED_TYPEALIAS_PARAMETER!>X<!>> = Test<T, X>
@@ -1,8 +1,9 @@
// !LANGUAGE: +VariableDeclarationInWhenSubject
// !DIAGNOSICS: +UNUSED_VARIABLE
fun foo(): Any = 42
fun test() {
when (val <!UNUSED_VARIABLE!>x<!> = foo()) {
}
}
}
@@ -1,4 +1,5 @@
// !LANGUAGE: +WarningOnMainUnusedParameter
// !DIAGNOSTICS: +UNUSED_PARAMETER
// FILE: a.kt
fun main(args: Array<String>) {}
@@ -7,4 +8,4 @@ fun main(args: Array<String>) {}
fun main(args: Array<String>) {}
// FILE: c.kt
fun foo() { main(arrayOf("a", "b")) }
fun foo() { main(arrayOf("a", "b")) }
@@ -1,4 +1,5 @@
// !LANGUAGE: +WarningOnMainUnusedParameter
// !DIAGNOSTICS: +UNUSED_PARAMETER
// FILE: a.kt
fun main(<!UNUSED_PARAMETER!>args<!>: Array<String>) {}
@@ -7,4 +8,4 @@ fun main(<!UNUSED_PARAMETER!>args<!>: Array<String>) {}
fun main(<!UNUSED_PARAMETER!>args<!>: Array<String>) {}
// FILE: c.kt
fun foo() { <!OVERLOAD_RESOLUTION_AMBIGUITY!>main<!>(arrayOf("a", "b")) }
fun foo() { <!OVERLOAD_RESOLUTION_AMBIGUITY!>main<!>(arrayOf("a", "b")) }