Fix JVM type mapping of arrays of type variables
#KT-4262 Fixed #KT-5056 Fixed
This commit is contained in:
@@ -262,10 +262,6 @@ public class JetTypeMapper {
|
||||
signatureVisitor.writeArrayEnd();
|
||||
}
|
||||
|
||||
if (memberType.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) {
|
||||
return AsmTypeConstants.getType(Object[].class);
|
||||
}
|
||||
|
||||
return Type.getType("[" + boxType(mapType(memberType, kind)).getDescriptor());
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
+10
@@ -1311,6 +1311,16 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/regressions/kt344.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4262.kt")
|
||||
public void testKt4262() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/regressions/kt4262.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt5056.kt")
|
||||
public void testKt5056() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/regressions/kt5056.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt528.kt")
|
||||
public void testKt528() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/regressions/kt528.kt");
|
||||
|
||||
@@ -202,6 +202,13 @@ class ArraysTest {
|
||||
assertEquals(listOf(100L, 200L, 30L), array(50L, 100L, 200L, 30L).slice(1..3))
|
||||
assertEquals(listOf(true, false, true), array(true, false, true, true).slice(iter))
|
||||
}
|
||||
|
||||
test fun toSortedList() {
|
||||
assertEquals(listOf<Nothing>(), array<Nothing>().toSortedList())
|
||||
assertEquals(listOf(1), array(1).toSortedList())
|
||||
assertEquals(listOf("aab", "aba", "ac"), array("ac", "aab", "aba").toSortedList())
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
TODO FIXME ASAP: These currently fail on JS due to missing upto() method on numbers
|
||||
|
||||
Reference in New Issue
Block a user