Unused symbol: fix false positive in anonymous object in top level or companion object

#KT-31800 Fixed
#KT-20868 Fixed
This commit is contained in:
Toshiaki Kameyama
2020-02-10 13:38:16 +09:00
committed by Vladimir Dolzhenko
parent ef1e54eda9
commit a3252b9480
10 changed files with 106 additions and 0 deletions
@@ -0,0 +1,14 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtNamedFunction
// OPTIONS: usages
class Foo {
companion object {
private val localObject = object : Any() {
fun <caret>f() {
}
}
}
fun bar() {
localObject.f()
}
}
@@ -0,0 +1 @@
Function call 12 localObject.f()
@@ -0,0 +1,12 @@
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtNamedFunction
// OPTIONS: usages
private val localObject = object : Any() {
fun <caret>f() {
}
}
class Foo {
fun bar() {
localObject.f()
}
}
@@ -0,0 +1 @@
Function call 10 localObject.f()
@@ -0,0 +1,16 @@
// PROBLEM: none
// WITH_RUNTIME
private val xs = listOf(1, 2, 3).flatMap { x ->
listOf(3, 4, 5).map { y ->
object {
val <caret>value = x + y
}
}
}
fun foo() {
xs.forEach {
println("value: " + it.value)
}
}
@@ -0,0 +1,13 @@
// PROBLEM: none
class Some {
fun bar() {
writer().sayHello()
}
companion object {
private fun writer() = object {
fun <caret>sayHello() {
}
}
}
}
@@ -0,0 +1,9 @@
// PROBLEM: none
fun main() {
writer.sayHello()
}
private val writer = object {
fun <caret>sayHello() {
}
}