d570b863ce
Introdude deprecation as per KT-21515. Warning is reported on type usage, that soon will became invisible. Quickfix by adding explicit import is added. Idea behind implementation is to mark scopes that are deprecated (see ClassResolutionScopesSupport). Then, during walk along hierarchy of scopes, look at deprecation status of the scope that has provided this classifier. Note that we also have to check if there are *some* non-deprecated visibility paths (because we can see classifier by two paths, e.g. if we've added explicit import) -- then this type reference shouldn't be treated as deprecated.
69 lines
1.4 KiB
Kotlin
Vendored
69 lines
1.4 KiB
Kotlin
Vendored
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
|
|
|
// ===== Case 1: LHS is a class
|
|
//
|
|
object A {
|
|
open class Base {
|
|
companion object {
|
|
class FromBaseCompanion {
|
|
fun foo() = 42
|
|
}
|
|
}
|
|
}
|
|
|
|
class Derived : Base() {
|
|
val a = A.Base.Companion.FromBaseCompanion::foo
|
|
}
|
|
}
|
|
|
|
// ===== Case 2: LHS is a class with companion object, function comes from class
|
|
|
|
object B {
|
|
open class Base {
|
|
companion object {
|
|
class FromBaseCompanion {
|
|
fun foo() = 42
|
|
|
|
companion object {}
|
|
}
|
|
}
|
|
}
|
|
|
|
class Derived : Base() {
|
|
val a = B.Base.Companion.FromBaseCompanion::foo
|
|
}
|
|
}
|
|
|
|
// ==== Case 3: LHS is a class with companion object, function comes from companion
|
|
|
|
object C {
|
|
open class Base {
|
|
companion object {
|
|
class FromBaseCompanion {
|
|
companion object {
|
|
fun foo() = 42
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class Derived : Base() {
|
|
val a = C.Base.Companion.FromBaseCompanion::<!UNRESOLVED_REFERENCE!>foo<!>
|
|
}
|
|
}
|
|
|
|
// ==== Case 4: LHS is an object
|
|
|
|
object D {
|
|
open class Base {
|
|
companion object {
|
|
object FromBaseCompanion {
|
|
fun foo() = 42
|
|
}
|
|
}
|
|
}
|
|
|
|
class Derived : Base() {
|
|
val a = D.Base.Companion.FromBaseCompanion::foo
|
|
}
|
|
} |