reflection - Is it safe to call kclass.memberProperties on an unknown (Any) object? -


i assumed it's ok access members field of kclass object. have found case when it's not. both tests throw exceptions.

@test fun mapproperties() {     val map = mapof("a" "b")     val cls = map.javaclass.kotlin     cls.members } 

throws: kotlin.reflect.kotlinreflectioninternalerror: incorrect resolution sequence java field public open val values: kotlin.collections.mutablecollection<(v..v?)> defined in java.util.collections.singletonmap[javapropertydescriptor@10163d6]

@test fun mapproperties2() {     val map = mapof("a" "b")     val cls = clsbyreified(map)     cls.members }  inline fun <reified t: any> clsbyreified(instance: t): kclass<t> {     return t::class } 

throws: kotlin.reflect.kotlinreflectioninternalerror: no metadata found public abstract val entries: [not-computed] defined in kotlin.collections.map[deserializedpropertydescriptor@5c1a8622]

not sure if stumbled upon bug or missing something.

this bug has been fixed , available in nightly builds. upcoming kotlin 1.0.2 release include fix. here's original issue: kt-11258.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -