Fix JVM type mapping of arrays of type variables

#KT-4262 Fixed
 #KT-5056 Fixed
This commit is contained in:
Alexander Udalov
2014-05-20 18:32:34 +04:00
parent 4e8d6d4882
commit af3d56b44e
5 changed files with 31 additions and 4 deletions
@@ -0,0 +1,10 @@
fun <E : Enum<E>> Byte.toEnum(clazz : Class<E>) : E =
(clazz.getMethod("values").invoke(null) as Array<E>)[this.toInt()]
enum class Letters { A B C }
fun box(): String {
val clazz = javaClass<Letters>()
val r = 1.toByte().toEnum(clazz)
return if (r == Letters.B) "OK" else "Fail: $r"
}
@@ -0,0 +1,4 @@
fun box(): String {
val list = array("a", "c", "b").toSortedList()
return if (list.toString() == "[a, b, c]") "OK" else "Fail: $list"
}