kotlinpoet
kotlinpoet copied to clipboard
KType can be more than just parameterized types or typevariable
This is kotlin's equivalent of a Type and can also just be a regular class. The current KType.asTypeName() is in ParameterizedTypeName.kt though, and should probably be generified and moved to TypeName.kt
looking further, it looks like this eventually routes through TypeName, maybe it should just be moved to there?
technically possible with typeOf() but that's marked as experimental. It would be pretty straightforward though, and could be used as basically just a proxy to KType.asTypeName()
@ExperimentalStdlibApi
inline fun <reified T> typeName(): TypeName {
val type = typeOf<T>()
return type.asTypeName()
}