Report warning on unused entities that can be renamed to _
Currently it's all about lambda parameters/destructuring entries #KT-14347 In Progress
This commit is contained in:
@@ -9,5 +9,5 @@ fun <A, B> Foo<A>.map(<!UNUSED_PARAMETER!>f<!>: (A) -> B): Foo<B> = object : Foo
|
||||
|
||||
fun foo() {
|
||||
val l: Foo<String> = object : Foo<String> {}
|
||||
val <!UNUSED_VARIABLE!>m<!>: Foo<String> = l.<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>map { ppp -> 1 }<!>
|
||||
}
|
||||
val <!UNUSED_VARIABLE!>m<!>: Foo<String> = l.<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>map { <!UNUSED_PARAMETER!>ppp<!> -> 1 }<!>
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@ fun <T> _arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : List<T> = throw Ex
|
||||
class _Pair<A>(val a: A)
|
||||
|
||||
fun test() {
|
||||
_arrayList(_Pair(1))._sortBy { it -> <!UNRESOLVED_REFERENCE!>xxx<!> }
|
||||
}
|
||||
_arrayList(_Pair(1))._sortBy { <!UNUSED_PARAMETER!>it<!> -> <!UNRESOLVED_REFERENCE!>xxx<!> }
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public inline fun <T: Closeable, R> T.use1(block: (T)-> R) : R {
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
C().use1 {
|
||||
w -> // ERROR here
|
||||
<!UNUSED_PARAMETER!>w<!> -> // ERROR here
|
||||
<!UNRESOLVED_REFERENCE!>x<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ enum class SomeEnum {
|
||||
|
||||
// Doesn't work
|
||||
fun Iterable<Int>.some() {
|
||||
this.fold(SomeEnum.FIRST, {res : SomeEnum, value ->
|
||||
this.fold(SomeEnum.FIRST, {res : SomeEnum, <!UNUSED_PARAMETER!>value<!> ->
|
||||
if (res == SomeEnum.FIRST) SomeEnum.FIRST else SomeEnum.SECOND
|
||||
})
|
||||
}
|
||||
@@ -19,7 +19,7 @@ fun tempFun() : SomeEnum {
|
||||
|
||||
// Doesn't work
|
||||
fun Iterable<Int>.someSimpleWithFun() {
|
||||
this.fold(SomeEnum.FIRST, {res : SomeEnum, value ->
|
||||
this.fold(SomeEnum.FIRST, {<!UNUSED_PARAMETER!>res<!> : SomeEnum, <!UNUSED_PARAMETER!>value<!> ->
|
||||
tempFun()
|
||||
})
|
||||
}
|
||||
@@ -27,17 +27,17 @@ fun Iterable<Int>.someSimpleWithFun() {
|
||||
|
||||
// Works
|
||||
fun Iterable<Int>.someSimple() {
|
||||
this.fold(SomeEnum.FIRST, {res : SomeEnum, value ->
|
||||
this.fold(SomeEnum.FIRST, {<!UNUSED_PARAMETER!>res<!> : SomeEnum, <!UNUSED_PARAMETER!>value<!> ->
|
||||
SomeEnum.FIRST
|
||||
})
|
||||
}
|
||||
|
||||
// Works
|
||||
fun Iterable<Int>.someInt() {
|
||||
this.fold(0, {res : Int, value ->
|
||||
this.fold(0, {res : Int, <!UNUSED_PARAMETER!>value<!> ->
|
||||
if (res == 0) 1 else 0
|
||||
})
|
||||
}
|
||||
|
||||
//from standard library
|
||||
fun <T,R> Iterable<T>.fold(<!UNUSED_PARAMETER!>initial<!>: R, <!UNUSED_PARAMETER!>operation<!>: (R, T) -> R): R {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T,R> Iterable<T>.fold(<!UNUSED_PARAMETER!>initial<!>: R, <!UNUSED_PARAMETER!>operation<!>: (R, T) -> R): R {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -15,10 +15,10 @@ fun SomeTemplate.query(f: (i: Int) -> Unit) = f
|
||||
fun SomeTemplate.query1(f: (i: Int) -> Unit) = f
|
||||
|
||||
fun test() {
|
||||
val mapperFunction = { i: Int -> }
|
||||
val mapperFunction = { <!UNUSED_PARAMETER!>i<!>: Int -> }
|
||||
SomeTemplate().query(mapperFunction)
|
||||
|
||||
// TYPE_MISMATCH: Required Class<[ERROR: CANT_INFER]>, Found (kotlin.Int) -> Unit
|
||||
SomeTemplate().query { i: Int -> }
|
||||
SomeTemplate().query1 { i: Int -> }
|
||||
SomeTemplate().query { <!UNUSED_PARAMETER!>i<!>: Int -> }
|
||||
SomeTemplate().query1 { <!UNUSED_PARAMETER!>i<!>: Int -> }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user