robstoll
06/17/2019, 4:47 PMinline fun <reified T> foo() = T::class.qualifiedName be disallowed if inline fun <reified T> foo() = T::class is?Shawn
06/17/2019, 4:50 PMShawn
06/17/2019, 4:50 PMinline fun <reified T : Any> foo(): KClass<T> = T::class
is what you want because KClass<T> is explicitly bounded to Anyrobstoll
06/17/2019, 4:51 PMinline fun <reified T> foo() = T::class.qualifiedName or to ask differently what is the type of T::class and how can I use it in other code 😄Shawn
06/17/2019, 4:52 PMString?Shawn
06/17/2019, 4:52 PMT in the return typeShawn
06/17/2019, 4:53 PMT::class is KClass<T>robstoll
06/17/2019, 4:54 PMKClass<T> requires T to have an upper bound of Any -- it's unsafe to ignore that no?robstoll
06/17/2019, 4:55 PMinline fun <reified T> foo() : String? {
val a: KClass<T> = T::class
return a.qualifiedName
}
Does not compilerobstoll
06/17/2019, 5:00 PMfoo<Int?>() returns <http://kotlin.Int|kotlin.Int>, no mentioning of the nullable partShawn
06/17/2019, 5:01 PMShawn
06/17/2019, 5:01 PMInt?::class won’t compilerobstoll
06/17/2019, 5:02 PMShawn
06/17/2019, 5:10 PM