Support KClass.defaultType

This commit is contained in:
Alexander Udalov
2015-08-25 12:40:56 +03:00
parent ea8fe56704
commit 7c28a2e732
3 changed files with 40 additions and 0 deletions
@@ -0,0 +1,25 @@
import kotlin.reflect.defaultType
import kotlin.reflect.jvm.javaType
import kotlin.test.assertEquals
import kotlin.test.assertNotEquals
class Simple
class Generic<K, V> {
fun thiz() = this
}
fun simple() = Simple()
fun genericIntString() = Generic<Int, String>()
fun box(): String {
assertEquals(javaClass<Simple>(), Simple::class.defaultType.javaType)
assertEquals(::simple.returnType, Simple::class.defaultType)
assertEquals(javaClass<Generic<*, *>>(), Generic::class.defaultType.javaType)
assertEquals(Generic<*, *>::thiz.returnType, Generic::class.defaultType)
// Generic<Int, String> != Generic<K, V>
assertNotEquals(::genericIntString.returnType, Generic::class.defaultType)
return "OK"
}
@@ -3012,6 +3012,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib(fileName);
}
@TestMetadata("defaultType.kt")
public void testDefaultType() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classes/defaultType.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("jvmName.kt")
public void testJvmName() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/classes/jvmName.kt");