Fix NPE on equals/hashCode for callable references without kotlin-reflect
#KT-11316 Fixed #KT-15847 Fixed
This commit is contained in:
Vendored
+9
@@ -11,6 +11,9 @@ class M {
|
||||
val bar = 1
|
||||
}
|
||||
|
||||
fun topLevelFun() {}
|
||||
val topLevelProp = ""
|
||||
|
||||
fun checkEquals(x: KCallable<*>, y: KCallable<*>) {
|
||||
assertEquals(x, y)
|
||||
assertEquals(y, x)
|
||||
@@ -26,9 +29,15 @@ fun box(): String {
|
||||
checkEquals(M::bar, M::bar)
|
||||
checkEquals(::M, ::M)
|
||||
|
||||
checkEquals(::topLevelFun, ::topLevelFun)
|
||||
checkEquals(::topLevelProp, ::topLevelProp)
|
||||
|
||||
checkToString(M::foo, "function foo")
|
||||
checkToString(M::bar, "property bar")
|
||||
checkToString(::M, "constructor")
|
||||
|
||||
checkToString(::topLevelFun, "function topLevelFun")
|
||||
checkToString(::topLevelProp, "property topLevelProp")
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KProperty
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
object Delegate {
|
||||
lateinit var prop: KProperty<*>
|
||||
|
||||
operator fun provideDelegate(thiz: Any?, p: KProperty<*>): Delegate {
|
||||
prop = p
|
||||
return this
|
||||
}
|
||||
|
||||
operator fun getValue(x: Any?, p: KProperty<*>) {
|
||||
assertEquals(prop, p)
|
||||
assertEquals(p, prop)
|
||||
assertEquals(p.hashCode(), prop.hashCode())
|
||||
assertEquals("property x (Kotlin reflection is not available)", p.toString())
|
||||
}
|
||||
}
|
||||
|
||||
val x: Unit by Delegate
|
||||
|
||||
fun box(): String {
|
||||
x
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user