Restore UNUSED_* diagnostics to relevant tests.

This commit is contained in:
Mark Punzalan
2021-03-30 05:17:42 +00:00
committed by Dmitriy Novozhilov
parent 303d5ece96
commit 1da35029a6
16 changed files with 87 additions and 44 deletions
@@ -0,0 +1,44 @@
// !DIAGNOSTICS: +UNUSED_PARAMETER
import kotlin.reflect.KProperty
class C(a: Int, b: Int, c: Int, d: Int, e: Int = d, val f: String) {
init {
a + a
}
val g = b
init {
c + c
}
}
fun f(a: Int, b: Int, c: Int = b) {
a + a
}
fun Any.getValue(thisRef: Any?, prop: KProperty<*>): String = ":)"
fun Any.setValue(thisRef: Any?, prop: KProperty<*>, value: String) {
}
fun Any.provideDelegate(thisRef: Any?, prop: KProperty<*>) {
}
operator fun Int.getValue(thisRef: Any?, prop: KProperty<*>): String = ":)"
operator fun Int.setValue(thisRef: Any?, prop: KProperty<*>, value: String) {
}
operator fun Int.provideDelegate(thisRef: Any?, prop: KProperty<*>) {
}
fun get(p: Any) {
}
fun set(p: Any) {
}
fun foo(s: String) {
s.<!UNRESOLVED_REFERENCE!>xxx<!> = 1
}
+8 -8
View File
@@ -1,7 +1,7 @@
// FIR_IDENTICAL // !DIAGNOSTICS: +UNUSED_PARAMETER
import kotlin.reflect.KProperty import kotlin.reflect.KProperty
class C(a: Int, b: Int, c: Int, d: Int, e: Int = d, val f: String) { class C(a: Int, b: Int, c: Int, d: Int, <!UNUSED_PARAMETER!>e<!>: Int = d, val f: String) {
init { init {
a + a a + a
} }
@@ -13,15 +13,15 @@ class C(a: Int, b: Int, c: Int, d: Int, e: Int = d, val f: String) {
} }
} }
fun f(a: Int, b: Int, c: Int = b) { fun f(a: Int, b: Int, <!UNUSED_PARAMETER!>c<!>: Int = b) {
a + a a + a
} }
fun Any.getValue(thisRef: Any?, prop: KProperty<*>): String = ":)" fun Any.getValue(<!UNUSED_PARAMETER!>thisRef<!>: Any?, <!UNUSED_PARAMETER!>prop<!>: KProperty<*>): String = ":)"
fun Any.setValue(thisRef: Any?, prop: KProperty<*>, value: String) { fun Any.setValue(<!UNUSED_PARAMETER!>thisRef<!>: Any?, <!UNUSED_PARAMETER!>prop<!>: KProperty<*>, <!UNUSED_PARAMETER!>value<!>: String) {
} }
fun Any.provideDelegate(thisRef: Any?, prop: KProperty<*>) { fun Any.provideDelegate(<!UNUSED_PARAMETER!>thisRef<!>: Any?, <!UNUSED_PARAMETER!>prop<!>: KProperty<*>) {
} }
operator fun Int.getValue(thisRef: Any?, prop: KProperty<*>): String = ":)" operator fun Int.getValue(thisRef: Any?, prop: KProperty<*>): String = ":)"
@@ -33,10 +33,10 @@ operator fun Int.provideDelegate(thisRef: Any?, prop: KProperty<*>) {
} }
fun get(p: Any) { fun get(<!UNUSED_PARAMETER!>p<!>: Any) {
} }
fun set(p: Any) { fun set(<!UNUSED_PARAMETER!>p<!>: Any) {
} }
fun foo(s: String) { fun foo(s: String) {
@@ -1,3 +1,4 @@
// !DIAGNOSTICS: +UNUSED_PARAMETER
var y: Int = 1 var y: Int = 1
// No backing field! // No backing field!
@@ -5,4 +6,4 @@ var x: Int
get() = y get() = y
set(field) { set(field) {
y = field y = field
} }
@@ -1,8 +1,9 @@
// !DIAGNOSTICS: +UNUSED_PARAMETER
var y: Int = 1 var y: Int = 1
// No backing field! // No backing field!
<!MUST_BE_INITIALIZED!>var x: Int<!> <!MUST_BE_INITIALIZED!>var x: Int<!>
get() = y get() = y
set(<!ACCESSOR_PARAMETER_NAME_SHADOWING!>field<!>) { set(<!ACCESSOR_PARAMETER_NAME_SHADOWING, UNUSED_PARAMETER!>field<!>) {
y = field y = field
} }
@@ -1,5 +1,5 @@
// !CHECK_TYPE // !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER +UNUSED_DESTRUCTURED_PARAMETER_ENTRY
data class A(val x: Int, val y: String) data class A(val x: Int, val y: String)
data class B(val u: Double, val w: Short) data class B(val u: Double, val w: Short)
@@ -1,5 +1,5 @@
// !CHECK_TYPE // !CHECK_TYPE
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_ANONYMOUS_PARAMETER +UNUSED_DESTRUCTURED_PARAMETER_ENTRY
data class A(val x: Int, val y: String) data class A(val x: Int, val y: String)
data class B(val u: Double, val w: Short) data class B(val u: Double, val w: Short)
@@ -7,36 +7,36 @@ fun foo(block: (A) -> Unit) { }
fun foobar(block: (A, B) -> Unit) { } fun foobar(block: (A, B) -> Unit) { }
fun bar() { fun bar() {
foo { (a, b) -> foo { (a, <!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>) ->
a checkType { _<Int>() } a checkType { _<Int>() }
} }
foo { (a, b) -> foo { (<!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>a<!>, b) ->
b checkType { _<String>() } b checkType { _<String>() }
} }
foo { (a: Int, b: String) -> foo { (a: Int, <!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>: String) ->
a checkType { _<Int>() } a checkType { _<Int>() }
} }
foo { (a: Int, b: String) -> foo { (<!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>a<!>: Int, b: String) ->
b checkType { _<String>() } b checkType { _<String>() }
} }
foobar { (a, b), c -> foobar { (a, <!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>), c ->
a checkType { _<Int>() } a checkType { _<Int>() }
} }
foobar { a, (b, c) -> foobar { a, (<!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>, c) ->
c checkType { _<Short>() } c checkType { _<Short>() }
} }
foobar { (a, b), (c, d) -> foobar { (a, <!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>b<!>), (<!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>c<!>, d) ->
a checkType { _<Int>() } a checkType { _<Int>() }
d checkType { _<Short>() } d checkType { _<Short>() }
} }
foobar { (a, b), (c, d) -> foobar { (<!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>a<!>, b), (c, <!UNUSED_DESTRUCTURED_PARAMETER_ENTRY!>d<!>) ->
b checkType { _<String>() } b checkType { _<String>() }
c checkType { _<Double>() } c checkType { _<Double>() }
} }
@@ -1,3 +1,4 @@
// !DIAGNOSTICS: +UNUSED_PARAMETER
fun f(p: Int): Int { fun f(p: Int): Int {
val p = 2 val p = 2
return p return p
@@ -1,4 +1,5 @@
fun f(p: Int): Int { // !DIAGNOSTICS: +UNUSED_PARAMETER
fun f(<!UNUSED_PARAMETER!>p<!>: Int): Int {
val <!NAME_SHADOWING!>p<!> = 2 val <!NAME_SHADOWING!>p<!> = 2
return p return p
} }
@@ -1,7 +1,8 @@
// !DIAGNOSTICS: +UNUSED_PARAMETER +UNUSED_LAMBDA_EXPRESSION +UNUSED_VARIABLE
fun f(i: Int) { fun f(i: Int) {
for (j in 1..100) { for (j in 1..100) {
{ {
var i = 12 var i = 12
} }
} }
} }
@@ -1,7 +1,8 @@
fun f(i: Int) { // !DIAGNOSTICS: +UNUSED_PARAMETER +UNUSED_LAMBDA_EXPRESSION +UNUSED_VARIABLE
fun f(<!UNUSED_PARAMETER!>i<!>: Int) {
for (j in 1..100) { for (j in 1..100) {
{ <!UNUSED_LAMBDA_EXPRESSION!>{
var <!NAME_SHADOWING!>i<!> = 12 var <!NAME_SHADOWING, UNUSED_VARIABLE!>i<!> = 12
} }<!>
} }
} }
@@ -1,7 +1,8 @@
// !DIAGNOSTICS: +UNUSED_LAMBDA_EXPRESSION +UNUSED_VARIABLE
fun ff(): Int { fun ff(): Int {
var i = 1 var i = 1
{ {
val i = 2 val i = 2
} }
return i return i
} }
@@ -1,7 +1,8 @@
// !DIAGNOSTICS: +UNUSED_LAMBDA_EXPRESSION +UNUSED_VARIABLE
fun ff(): Int { fun ff(): Int {
var i = 1 var i = 1
{ <!UNUSED_LAMBDA_EXPRESSION!>{
val <!NAME_SHADOWING!>i<!> = 2 val <!NAME_SHADOWING, UNUSED_VARIABLE!>i<!> = 2
} }<!>
return i return i
} }
@@ -1,5 +1,6 @@
// !DIAGNOSTICS: +UNUSED_LAMBDA_EXPRESSION +UNUSED_VARIABLE
fun f(): Int { fun f(): Int {
var i = 17 var i = 17
{ var i = 18 } { var i = 18 }
return i return i
} }
@@ -1,5 +1,6 @@
// !DIAGNOSTICS: +UNUSED_LAMBDA_EXPRESSION +UNUSED_VARIABLE
fun f(): Int { fun f(): Int {
var i = 17 var i = 17
{ var <!NAME_SHADOWING!>i<!> = 18 } <!UNUSED_LAMBDA_EXPRESSION!>{ var <!NAME_SHADOWING, UNUSED_VARIABLE!>i<!> = 18 }<!>
return i return i
} }
@@ -1,12 +0,0 @@
// !LANGUAGE: +NewInference
import kotlin.test.assertEquals
fun test() {
val u = when (true) {
true -> 42
else -> 1.0
}
assertEquals(42, u)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference // !LANGUAGE: +NewInference
import kotlin.test.assertEquals import kotlin.test.assertEquals