Fix false positive "Redundant lambda arrow" inspection

#KT-29590 Fixed
 #KT-19462 Fixed
 #KT-29124 Fixed
This commit is contained in:
Dmitry Gridin
2019-03-13 17:33:21 +07:00
parent 49ee197578
commit 479e812bbc
15 changed files with 267 additions and 47 deletions
@@ -0,0 +1,12 @@
class A
fun A.foo(f: (String) -> Unit) {}
fun print(s: String) {}
fun bar() {
A().foo { <caret>it ->
print(it)
print(it)
}
}
@@ -0,0 +1,12 @@
class A
fun A.foo(f: (String) -> Unit) {}
fun print(s: String) {}
fun bar() {
A().foo {
print(it)
print(it)
}
}
@@ -0,0 +1,10 @@
// PROBLEM: none
// WITH_RUNTIME
fun main() {
MyClass { _<caret>: String -> 0 }
}
class MyClass<K, V>(
private val selector: (K) -> V
)
@@ -0,0 +1,10 @@
// PROBLEM: none
// WITH_RUNTIME
fun main() {
MyClass { it<caret>: String -> 0 }
}
class MyClass<K, V>(
private val selector: (K) -> V
)
@@ -0,0 +1,9 @@
// PROBLEM: none
// WITH_RUNTIME
fun bar(f: () -> Unit) {}
fun bar(f: (Int) -> Unit) {}
fun test() {
bar { -><caret> }
}
@@ -0,0 +1,9 @@
// PROBLEM: none
// WITH_RUNTIME
fun bar(f: () -> Unit) {}
fun bar(f: (Int) -> Unit) {}
fun test() {
bar({ -><caret> })
}
@@ -0,0 +1,9 @@
// PROBLEM: none
// WITH_RUNTIME
fun bar(f: () -> Unit) {}
fun bar(f: (Int) -> Unit) {}
fun test() {
bar(f = { -><caret> })
}
@@ -0,0 +1,9 @@
// WITH_RUNTIME
// PROBLEM: none
fun bar(f: () -> Unit) {}
fun bar(f: (Int) -> Unit) {}
fun test() {
bar { it<caret> -> }
}
@@ -0,0 +1,13 @@
// PROBLEM: none
// WITH_RUNTIME
fun main() {
registerHandler(handlers = *arrayOf(
{ _<caret> -> },
{ it -> }
))
}
fun registerHandler(vararg handlers: (String) -> Unit) {
handlers.forEach { it.invoke("hello") }
}
@@ -0,0 +1,13 @@
// PROBLEM: none
// WITH_RUNTIME
fun main() {
registerHandler(handlers = *arrayOf(
{ _ -> },
{ it<caret> -> }
))
}
fun registerHandler(vararg handlers: (String) -> Unit) {
handlers.forEach { it.invoke("hello") }
}
@@ -0,0 +1,8 @@
// WITH_RUNTIME
fun bar(f: () -> Unit) {}
fun bar(g: (Int, Int) -> Unit) {}
fun test() {
bar(f = { -><caret> })
}
@@ -0,0 +1,8 @@
// WITH_RUNTIME
fun bar(f: () -> Unit) {}
fun bar(g: (Int, Int) -> Unit) {}
fun test() {
bar(f = { })
}