Fix several false positives and make safer "redundant companion ref"

Don't report it on an import directive #KT-23520 Fixed
Don't report it if companion nested class is referenced #KT-23519 Fixed
Check companion reference both by descriptor and by name
This commit is contained in:
Mikhail Glukhikh
2018-04-02 21:23:05 +03:00
parent 23488fac56
commit ab973b2ff0
7 changed files with 88 additions and 9 deletions
@@ -0,0 +1,11 @@
// PROBLEM: none
class Owner {
companion object {
class InCompanion {
class Nested
}
}
}
val y = Owner.<caret>Companion.InCompanion.Nested()
@@ -0,0 +1,9 @@
// PROBLEM: none
class Owner {
companion object {
class InCompanion
}
}
val y = Owner.<caret>Companion.InCompanion()
@@ -0,0 +1,13 @@
// PROBLEM: none
import Owner.<caret>Companion.some
class Owner {
companion object {
const val some = ""
}
}
class User {
val anything = some
}
@@ -0,0 +1,9 @@
class C {
companion object Obj {
fun create() = C()
}
}
fun test() {
C.<caret>Obj.create()
}
@@ -0,0 +1,9 @@
class C {
companion object Obj {
fun create() = C()
}
}
fun test() {
C.create()
}