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.
This commit is contained in:
Dmitry Savvinov
2017-12-14 18:59:32 +03:00
parent acd8edaa9c
commit d570b863ce
117 changed files with 8027 additions and 113 deletions
@@ -0,0 +1,29 @@
package foo
import foo.CallableReferenceOnClass.Base.Companion.FromBaseCompanion
import foo.CallableReferenceOnClass.CompanionSupertype.FromCompanionSupertype
object CallableReferenceOnClass {
open class Base {
companion object {
class FromBaseCompanion {
fun foo() = 42
}
}
}
open class CompanionSupertype {
class FromCompanionSupertype {
fun foo() = 42
}
}
}
class Derived : CallableReferenceOnClass.Base() {
companion object : CallableReferenceOnClass.CompanionSupertype() { }
// Callable references
val c = FromBaseCompanion::foo
val d = FromCompanionSupertype::foo
}
@@ -0,0 +1,29 @@
package foo
import foo.CallableReferenceOnClass.Base.Companion.FromBaseCompanion
import foo.CallableReferenceOnClass.CompanionSupertype.FromCompanionSupertype
object CallableReferenceOnClass {
open class Base {
companion object {
class FromBaseCompanion {
fun foo() = 42
}
}
}
open class CompanionSupertype {
class FromCompanionSupertype {
fun foo() = 42
}
}
}
class Derived : CallableReferenceOnClass.Base() {
companion object : CallableReferenceOnClass.CompanionSupertype() { }
// Callable references
val c = FromBaseCompanion::foo
val d = FromCompanionSupertype::foo
}
@@ -0,0 +1,35 @@
package foo
import foo.CallableReferenceOnClassWithCompanion.Base.Companion.FromBaseCompanion
import foo.CallableReferenceOnClassWithCompanion.CompanionSupertype.FromCompanionSupertype
object CallableReferenceOnClassWithCompanion {
open class Base {
companion object {
class FromBaseCompanion {
fun foo() = 42
// We need it to cover another code-path
companion object
}
}
}
open class CompanionSupertype {
class FromCompanionSupertype {
fun foo() = 42
// We need it to cover another code-path
companion object
}
}
}
class Derived : CallableReferenceOnClassWithCompanion.Base() {
companion object : CallableReferenceOnClassWithCompanion.CompanionSupertype() { }
// Callable references
val c = FromBaseCompanion::foo
val d = FromCompanionSupertype::foo
}
@@ -0,0 +1,35 @@
package foo
import foo.CallableReferenceOnClassWithCompanion.Base.Companion.FromBaseCompanion
import foo.CallableReferenceOnClassWithCompanion.CompanionSupertype.FromCompanionSupertype
object CallableReferenceOnClassWithCompanion {
open class Base {
companion object {
class FromBaseCompanion {
fun foo() = 42
// We need it to cover another code-path
companion object
}
}
}
open class CompanionSupertype {
class FromCompanionSupertype {
fun foo() = 42
// We need it to cover another code-path
companion object
}
}
}
class Derived : CallableReferenceOnClassWithCompanion.Base() {
companion object : CallableReferenceOnClassWithCompanion.CompanionSupertype() { }
// Callable references
val c = FromBaseCompanion::foo
val d = FromCompanionSupertype::foo
}
@@ -0,0 +1,29 @@
package foo
import foo.CallableReferenceOnObject.Base.Companion.FromBaseCompanion
import foo.CallableReferenceOnObject.CompanionSupertype.FromCompanionSupertype
object CallableReferenceOnObject {
open class Base {
companion object {
object FromBaseCompanion {
fun foo() = 42
}
}
}
open class CompanionSupertype {
object FromCompanionSupertype {
fun foo() = 42
}
}
}
class Derived : CallableReferenceOnObject.Base() {
companion object : CallableReferenceOnObject.CompanionSupertype() { }
// Callable references
val c = FromBaseCompanion::foo
val d = FromCompanionSupertype::foo
}
@@ -0,0 +1,29 @@
package foo
import foo.CallableReferenceOnObject.Base.Companion.FromBaseCompanion
import foo.CallableReferenceOnObject.CompanionSupertype.FromCompanionSupertype
object CallableReferenceOnObject {
open class Base {
companion object {
object FromBaseCompanion {
fun foo() = 42
}
}
}
open class CompanionSupertype {
object FromCompanionSupertype {
fun foo() = 42
}
}
}
class Derived : CallableReferenceOnObject.Base() {
companion object : CallableReferenceOnObject.CompanionSupertype() { }
// Callable references
val c = FromBaseCompanion::foo
val d = FromCompanionSupertype::foo
}
@@ -0,0 +1,30 @@
package foo
import foo.Constructors.Base.Companion.FromBaseCompanion
import foo.Constructors.CompanionSupertype.FromCompanionSupertype
object Constructors {
open class Base {
companion object {
class FromBaseCompanion {
fun foo() = 42
}
}
}
open class CompanionSupertype {
class FromCompanionSupertype {
fun foo() = 42
}
}
}
class Derived : Constructors.Base() {
companion object : Constructors.CompanionSupertype() {
}
// Constructors
val e = FromBaseCompanion()
val f = FromCompanionSupertype()
}
@@ -0,0 +1,30 @@
package foo
import foo.Constructors.Base.Companion.FromBaseCompanion
import foo.Constructors.CompanionSupertype.FromCompanionSupertype
object Constructors {
open class Base {
companion object {
class FromBaseCompanion {
fun foo() = 42
}
}
}
open class CompanionSupertype {
class FromCompanionSupertype {
fun foo() = 42
}
}
}
class Derived : Constructors.Base() {
companion object : Constructors.CompanionSupertype() {
}
// Constructors
val e = FromBaseCompanion()
val f = FromCompanionSupertype()
}
@@ -0,0 +1,30 @@
package foo
import foo.TypeReference.Base.Companion.FromBaseCompanion
import foo.TypeReference.CompanionSupertype.FromCompanionSupertype
object TypeReference {
open class Base {
companion object {
class FromBaseCompanion {
fun foo() = 42
}
}
}
open class CompanionSupertype {
class FromCompanionSupertype {
fun foo() = 42
}
}
}
class Derived : TypeReference.Base() {
companion object : TypeReference.CompanionSupertype() {
}
// Type references
val a: FromBaseCompanion? = null
val b: FromCompanionSupertype? = null
}
@@ -0,0 +1,30 @@
package foo
import foo.TypeReference.Base.Companion.FromBaseCompanion
import foo.TypeReference.CompanionSupertype.FromCompanionSupertype
object TypeReference {
open class Base {
companion object {
class FromBaseCompanion {
fun foo() = 42
}
}
}
open class CompanionSupertype {
class FromCompanionSupertype {
fun foo() = 42
}
}
}
class Derived : TypeReference.Base() {
companion object : TypeReference.CompanionSupertype() {
}
// Type references
val a: FromBaseCompanion? = null
val b: FromCompanionSupertype? = null
}