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"
}