Reflection: deprecate KClass.defaultType

Its semantics were unclear and its javaType was implemented incorrectly (it
should have returned ParameterizedType with star projections for generic type)
This commit is contained in:
Alexander Udalov
2016-07-26 18:41:41 +03:00
parent 6b79782951
commit f958483e56
3 changed files with 3 additions and 33 deletions
@@ -1,27 +0,0 @@
// WITH_REFLECT
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(Simple::class.java, Simple::class.defaultType.javaType)
assertEquals(::simple.returnType, Simple::class.defaultType)
assertEquals(Generic::class.java, 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"
}
@@ -11892,12 +11892,6 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("defaultType.kt")
public void testDefaultType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/classes/defaultType.kt");
doTest(fileName);
}
@TestMetadata("jvmName.kt")
public void testJvmName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/reflection/classes/jvmName.kt");