Files
kotlin-fork/compiler/testData/diagnostics/tests/scopes/inheritance/nestedCompanionClassVsNested.kt
T
Dmitry Savvinov d570b863ce Introduce deprecation of companion objects nested classes
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.
2018-02-21 16:04:49 +03:00

95 lines
1.6 KiB
Kotlin
Vendored

// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
open class A {
class X {
fun A_X() {}
}
class Y {
fun A_Y() {}
}
companion object {
class X {
fun A_C_X() {}
}
class Z {
fun A_C_Z() {}
}
}
init {
X().A_X()
X().<!UNRESOLVED_REFERENCE!>A_C_X<!>()
}
}
class Simple: A() {
init {
Y().A_Y()
<!DEPRECATED_ACCESS_BY_SHORT_NAME!>Z()<!>.A_C_Z()
}
}
class B: A() {
class Y {
fun B_Y() {}
}
class Z {
fun B_Z() {}
}
init {
X().A_X()
X().<!UNRESOLVED_REFERENCE!>A_C_X<!>()
Y().B_Y()
Y().<!UNRESOLVED_REFERENCE!>A_Y<!>()
Z().B_Z()
Z().<!UNRESOLVED_REFERENCE!>A_C_Z<!>()
}
companion object {
init {
X().A_X()
X().<!UNRESOLVED_REFERENCE!>A_C_X<!>()
Y().B_Y()
Y().<!UNRESOLVED_REFERENCE!>A_Y<!>()
Z().B_Z()
Z().<!UNRESOLVED_REFERENCE!>A_C_Z<!>()
}
}
}
class C: A() {
companion object {
class Y {
fun C_C_Y() {}
}
class Z {
fun C_C_Z() {}
}
init {
Y().C_C_Y()
Y().<!UNRESOLVED_REFERENCE!>A_Y<!>()
Z().C_C_Z()
Z().<!UNRESOLVED_REFERENCE!>A_C_Z<!>()
}
}
init {
Y().C_C_Y()
Y().<!UNRESOLVED_REFERENCE!>A_Y<!>()
Z().C_C_Z()
Z().<!UNRESOLVED_REFERENCE!>A_C_Z<!>()
}
}