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

This commit is contained in:
Dmitriy Novozhilov
2021-03-29 12:14:16 +03:00
committed by TeamCityServer
parent 85949b387e
commit cd890d5833
758 changed files with 1832 additions and 3745 deletions
@@ -1,13 +0,0 @@
package foo
fun dispatch(request: Request) {
val url = request.getRequestURI() as String
if (request.getMethod()?.length != 0) {
}
}
interface Request {
fun getRequestURI(): String?
fun getMethod(): String?
}
@@ -1,7 +1,8 @@
// FIR_IDENTICAL
package foo
fun dispatch(request: Request) {
val <!UNUSED_VARIABLE!>url<!> = request.getRequestURI() as String
val url = request.getRequestURI() as String
if (request.getMethod()?.length != 0) {
}
@@ -1,6 +1,6 @@
package aaa
fun bar(<!UNUSED_PARAMETER!>a<!>: Int, <!UNUSED_PARAMETER!>b<!>: Int) {}
fun bar(a: Int, b: Int) {}
fun foo(a: Int?) {
bar(a!!, <!DEBUG_INFO_SMARTCAST!>a<!>)
@@ -4,7 +4,7 @@ class IncDec {
fun foo(): IncDec {
var x = IncDec()
x = <!UNUSED_CHANGED_VALUE!>x<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>++<!><!>
x = x<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>++<!>
x<!INC_DEC_SHOULD_NOT_RETURN_UNIT!>++<!>
return x
}
@@ -1,7 +1,7 @@
package a
fun <T> foo(u: T, <!UNUSED_PARAMETER!>v<!>: T): T = u
fun <T> foo(u: T, v: T): T = u
fun test(s: String?) {
val <!UNUSED_VARIABLE!>r<!>: String = foo(s!!, <!DEBUG_INFO_SMARTCAST!>s<!>)
}
val r: String = foo(s!!, <!DEBUG_INFO_SMARTCAST!>s<!>)
}
@@ -32,7 +32,7 @@ fun test(a: A, b: B, c: C) {
checkSubtype<A>(k)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><B>(k)
val l: Int = three(a, b, c)
use(d, e, f, g, h, k, l)
}
}
@@ -7,9 +7,9 @@ import checkSubtype
fun <T> id(t: T): T = t
fun <T> two(u: T, <!UNUSED_PARAMETER!>v<!>: T): T = u
fun <T> two(u: T, v: T): T = u
fun <T> three(<!UNUSED_PARAMETER!>a<!>: T, <!UNUSED_PARAMETER!>b<!>: T, c: T): T = c
fun <T> three(a: T, b: T, c: T): T = c
interface A
interface B: A
@@ -32,12 +32,12 @@ fun test(a: A, b: B, c: C) {
checkSubtype<A>(k)
checkSubtype<B>(<!TYPE_MISMATCH!>k<!>)
val l: Int = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH{OI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH{NI}!>three(a, b, c)<!>
use(d, e, f, g, h, k, l)
}
}
fun <T> foo(t: T, <!UNUSED_PARAMETER!>l<!>: MutableList<T>): T = t
fun <T> foo(t: T, l: MutableList<T>): T = t
fun testErrorMessages(a: A, ml: MutableList<String>) {
if (a is B && a is C) {
@@ -58,6 +58,6 @@ fun rr(s: String?) {
}
//from library
fun <T> arrayListOf(vararg <!UNUSED_PARAMETER!>values<!>: T): MutableList<T> = throw Exception()
fun <T> arrayListOf(vararg values: T): MutableList<T> = throw Exception()
fun use(vararg a: Any) = a
@@ -35,6 +35,4 @@ public data class Tag(public var tagName: String) {
//from library
operator fun <K, V> MutableMap<K, V>.set(key : K, value : V) = this.put(key, value)
fun <T> arrayListOf(vararg <!UNUSED_PARAMETER!>values<!>: T): MutableList<T> = throw Exception()
fun <T> arrayListOf(vararg values: T): MutableList<T> = throw Exception()
@@ -1,10 +1,10 @@
//KT-2746 Do.smartcasts in inference
class C<T>(<!UNUSED_PARAMETER!>t<!> :T)
class C<T>(t :T)
fun test1(a: Any) {
if (a is String) {
val <!UNUSED_VARIABLE!>c<!>: C<String> = C(<!DEBUG_INFO_SMARTCAST!>a<!>)
val c: C<String> = C(<!DEBUG_INFO_SMARTCAST!>a<!>)
}
}
@@ -13,6 +13,6 @@ fun <T> f(t :T): C<T> = C(t)
fun test2(a: Any) {
if (a is String) {
val <!UNUSED_VARIABLE!>c1<!>: C<String> = f(<!DEBUG_INFO_SMARTCAST!>a<!>)
val c1: C<String> = f(<!DEBUG_INFO_SMARTCAST!>a<!>)
}
}
@@ -10,7 +10,7 @@ fun main() {
}
}
fun foo(<!UNUSED_PARAMETER!>map<!>: Pair<String, String>) {}
fun foo(map: Pair<String, String>) {}
//from library
@@ -7,5 +7,5 @@ fun <T> T.f(): T = this
fun test(a: A) {
if (a !is B) return
val <!UNUSED_VARIABLE!>c<!> = <!DEBUG_INFO_SMARTCAST!>a<!>.f() // type mismatch
}
val c = <!DEBUG_INFO_SMARTCAST!>a<!>.f() // type mismatch
}
@@ -3,7 +3,7 @@
interface SelfJson
object A {
fun find(<!UNUSED_PARAMETER!>clz<!>:Class<*>){ }
fun find(clz:Class<*>){ }
fun toJson2(obj:Any){
if(obj is SelfJson){
@@ -1,18 +0,0 @@
//KT-1461 Front-end complains on overload resolution when superclass property is accessed from string template and implicit type cast is performed
package f
open class Super(val property : String) {}
class Sub(str : String) : Super(str) {}
fun foo(sup : Super, sub : Sub) {
if (sup is Sub) {
println("${sup.property}")
println(sup.property)
}
println("${sub.property}")
println(sub.property)
}
//from library
fun println(message : Any?) { throw Exception() }
+2 -1
View File
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
//KT-1461 Front-end complains on overload resolution when superclass property is accessed from string template and implicit type cast is performed
package f
@@ -15,4 +16,4 @@ fun foo(sup : Super, sub : Sub) {
}
//from library
fun println(<!UNUSED_PARAMETER!>message<!> : Any?) { throw Exception() }
fun println(message : Any?) { throw Exception() }
+1 -1
View File
@@ -1,5 +1,5 @@
// !WITH_NEW_INFERENCE
operator fun <K, V> MutableMap<K, V>.set(<!UNUSED_PARAMETER!>k<!>: K, <!UNUSED_PARAMETER!>v<!>: V) {}
operator fun <K, V> MutableMap<K, V>.set(k: K, v: V) {}
fun foo(a: MutableMap<String, String>, x: String?) {
a[x!!] = <!DEBUG_INFO_SMARTCAST!>x<!>
+2 -2
View File
@@ -4,6 +4,6 @@ infix fun String.to(second: String) = StringPair(this, second)
fun f(a: String?) {
if (a != null) {
val <!UNUSED_VARIABLE!>b<!>: StringPair = <!DEBUG_INFO_SMARTCAST!>a<!> to <!DEBUG_INFO_SMARTCAST!>a<!>
val b: StringPair = <!DEBUG_INFO_SMARTCAST!>a<!> to <!DEBUG_INFO_SMARTCAST!>a<!>
}
}
}
@@ -9,5 +9,5 @@ fun F() : MutableMap<String, String> {
val value: String? = "xyz"
if (value == null) throw Error()
// Smart cast should be here
return hashMapOf("sss" to value)
}
return hashMapOf("sss" to value)
}
+3 -3
View File
@@ -2,12 +2,12 @@ data class StringPair(val first: String, val second: String)
infix fun String.to(second: String) = StringPair(this, second)
fun hashMapOf(<!UNUSED_PARAMETER!>pair<!>: StringPair): MutableMap<String, String> {
fun hashMapOf(pair: StringPair): MutableMap<String, String> {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun F() : MutableMap<String, String> {
val value: String? = "xyz"
if (value == null) throw Error()
// Smart cast should be here
return hashMapOf("sss" to <!DEBUG_INFO_SMARTCAST!>value<!>)
}
return hashMapOf("sss" to <!DEBUG_INFO_SMARTCAST!>value<!>)
}
@@ -2,7 +2,7 @@
inline fun <T> foo(t1: T, t2: T) = t1 ?: t2
inline fun <T> bar(<!UNUSED_PARAMETER!>l<!>: (T) -> Unit): T = null!!
inline fun <T> bar(l: (T) -> Unit): T = null!!
fun use() {
var x: Int?
@@ -2,7 +2,7 @@
// See KT-9143: smart cast on a variable nulled inside a lambda argument
inline fun <T> foo(t1: T, t2: T) = t1 ?: t2
inline fun <T> bar(<!UNUSED_PARAMETER!>l<!>: (T) -> Unit): T = null!!
inline fun <T> bar(l: (T) -> Unit): T = null!!
fun use() {
var x: Int?
@@ -22,5 +22,5 @@ val foofoo: Foo = <!TYPE_INFERENCE_UPPER_BOUND_VIOLATED{OI}!>run<!> {
val bar: Bar = <!TYPE_MISMATCH{NI}!><!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS{OI}!>run<!> {
val x = foo()
if (x == null) throw Exception()
<!DEBUG_INFO_SMARTCAST{NI}, TYPE_MISMATCH{NI}, TYPE_MISMATCH!>x<!>
<!DEBUG_INFO_SMARTCAST{NI}, TYPE_MISMATCH, TYPE_MISMATCH!>x<!>
}<!>
@@ -1,6 +1,6 @@
// See also KT-7817
fun <R> synchronized(<!UNUSED_PARAMETER!>lock<!>: Any, block: () -> R): R = block()
fun <R> synchronized(lock: Any, block: () -> R): R = block()
class My {
val test: String
@@ -11,4 +11,4 @@ class My {
}
<!DEBUG_INFO_SMARTCAST!>x<!>
}
}
}
@@ -2,7 +2,7 @@
fun trans(n: Int, f: () -> Boolean) = if (f()) n else null
fun foo() {
var i: Int? = 5
var i: Int? = 5
if (i != null) {
fun can(): Boolean {
i = null
@@ -2,14 +2,14 @@
fun trans(n: Int, f: () -> Boolean) = if (f()) n else null
fun foo() {
var i: Int? = 5
var i: Int? = 5
if (i != null) {
fun can(): Boolean {
i = null
return true
}
<!SMARTCAST_IMPOSSIBLE!>i<!>.hashCode()
trans(<!SMARTCAST_IMPOSSIBLE{NI}, SMARTCAST_IMPOSSIBLE!>i<!>, ::can)
trans(<!SMARTCAST_IMPOSSIBLE, SMARTCAST_IMPOSSIBLE!>i<!>, ::can)
<!SMARTCAST_IMPOSSIBLE!>i<!>.hashCode()
}
}
@@ -2,9 +2,9 @@ fun x(): Boolean { return true }
public fun foo(p: String?): Int {
// Exotic variant with unused literal
do <!UNUSED_LAMBDA_EXPRESSION!>{ ->
do { ->
p!!.length
}<!> while (!x())
} while (!x())
// Literal is not called so p.length is unsafe
return p<!UNSAFE_CALL!>.<!>length
}
}
@@ -17,7 +17,7 @@ fun foo(): Int {
k.run()
val d: Int = <!DEBUG_INFO_SMARTCAST!>c<!>
// a is captured so smart cast is not possible
return d + <!SMARTCAST_IMPOSSIBLE{NI}, SMARTCAST_IMPOSSIBLE!>a<!>
return d + <!SMARTCAST_IMPOSSIBLE, SMARTCAST_IMPOSSIBLE!>a<!>
}
else return -1
}
@@ -71,7 +71,7 @@ class A(val y: Int)
fun kt7491_1() {
val x: A? = A(42)
val <!UNUSED_VARIABLE!>z<!> = x?.y ?: return
val z = x?.y ?: return
<!DEBUG_INFO_SMARTCAST!>x<!>.y
}
@@ -6,5 +6,5 @@ fun foo(x: Int, f: () -> Unit, y: Int) {}
fun bar() {
var x: Int?
x = 4
foo(<!DEBUG_INFO_SMARTCAST!>x<!>, { x = null; x<!UNSAFE_CALL!>.<!>hashCode() }, <!SMARTCAST_IMPOSSIBLE{NI}, SMARTCAST_IMPOSSIBLE!>x<!>)
foo(<!DEBUG_INFO_SMARTCAST!>x<!>, { x = null; x<!UNSAFE_CALL!>.<!>hashCode() }, <!SMARTCAST_IMPOSSIBLE, SMARTCAST_IMPOSSIBLE!>x<!>)
}
@@ -7,5 +7,5 @@ fun bar(s: String): Int {
fun foo(m: MyClass): Int {
m.p = "xyz"
return bar(<!SMARTCAST_IMPOSSIBLE{NI}, SMARTCAST_IMPOSSIBLE!>m.p<!>)
return bar(<!SMARTCAST_IMPOSSIBLE, SMARTCAST_IMPOSSIBLE!>m.p<!>)
}
@@ -55,7 +55,7 @@ fun test4() {
fun test5() {
var a: Int?// = null
try {
<!UNUSED_VALUE!>a =<!> 3
a = 3
}
catch (e: Exception) {
return
@@ -68,7 +68,7 @@ fun test5() {
fun test6() {
var a: Int?// = null
try {
<!UNUSED_VALUE!>a =<!> 3
a = 3
}
catch (e: Exception) {
return
@@ -9,7 +9,7 @@ fun IntArray.forEachIndexed( op: (i: Int, value: Int) -> Unit) {
fun max(a: IntArray): Int? {
var maxI: Int? = null
a.forEachIndexed { i, value ->
if (maxI == null || value >= a[<!SMARTCAST_IMPOSSIBLE{NI}, SMARTCAST_IMPOSSIBLE!>maxI<!>])
if (maxI == null || value >= a[<!SMARTCAST_IMPOSSIBLE, SMARTCAST_IMPOSSIBLE!>maxI<!>])
maxI = i
}
return maxI
@@ -1,9 +0,0 @@
public fun foo() {
var i: Int? = 1
if (i != null) {
while (i != 10) {
i<!UNSAFE_CALL!>++<!> // Here smart cast should not be performed due to a successor
i = null
}
}
}
@@ -1,9 +1,10 @@
// FIR_IDENTICAL
public fun foo() {
var i: Int? = 1
if (i != null) {
while (i != 10) {
<!UNUSED_CHANGED_VALUE!>i<!UNSAFE_CALL!>++<!><!> // Here smart cast should not be performed due to a successor
i<!UNSAFE_CALL!>++<!> // Here smart cast should not be performed due to a successor
i = null
}
}
}
}