Delete kotlin.jvm.internal.KObject
It was supposed to be used in reflection but the benefits do not outweigh the cost of KT-6951 #KT-3223 Fixed #KT-6951 Fixed
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
// KT-4485 getGenericInterfaces vs getInterfaces for kotlin classes
|
||||
|
||||
import kotlin.jvm.internal.KObject
|
||||
|
||||
class SimpleClass
|
||||
|
||||
class ClassWithNonGenericSuperInterface: Cloneable
|
||||
@@ -10,10 +8,6 @@ class ClassWithGenericSuperInterface: java.util.Comparator<String> {
|
||||
override fun compare(a: String, b: String): Int = 0
|
||||
}
|
||||
|
||||
class ExplicitKObject: java.util.Comparator<String>, KObject {
|
||||
override fun compare(a: String, b: String): Int = 0
|
||||
}
|
||||
|
||||
fun check(klass: Class<*>) {
|
||||
val interfaces = klass.getInterfaces().toList()
|
||||
val genericInterfaces = klass.getGenericInterfaces().toList()
|
||||
@@ -26,6 +20,5 @@ fun box(): String {
|
||||
check(javaClass<SimpleClass>())
|
||||
check(javaClass<ClassWithNonGenericSuperInterface>())
|
||||
check(javaClass<ClassWithGenericSuperInterface>())
|
||||
check(javaClass<ExplicitKObject>())
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// KT-5609: interfaces should not inherit from KObject, unless explicitly said so
|
||||
|
||||
trait A
|
||||
|
||||
trait B : kotlin.jvm.internal.KObject
|
||||
|
||||
annotation class C
|
||||
|
||||
class D
|
||||
|
||||
class E : kotlin.jvm.internal.KObject
|
||||
|
||||
fun box(): String {
|
||||
val a = javaClass<A>().getGenericInterfaces().toList()
|
||||
if (a.toString() != "[]") return "Fail A: $a"
|
||||
|
||||
val b = javaClass<B>().getGenericInterfaces().toList()
|
||||
if (b.toString() != "[interface kotlin.jvm.internal.KObject]") return "Fail B: $b"
|
||||
|
||||
val c = javaClass<C>().getGenericInterfaces().toList()
|
||||
if (c.toString() != "[interface java.lang.annotation.Annotation]") return "Fail C: $c"
|
||||
|
||||
val d = javaClass<D>().getGenericInterfaces().toList()
|
||||
if (d.toString() != "[interface kotlin.jvm.internal.KObject]") return "Fail D: $d"
|
||||
|
||||
val e = javaClass<E>().getGenericInterfaces().toList()
|
||||
if (e.toString() != "[interface kotlin.jvm.internal.KObject]") return "Fail E: $e"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user