```fun main() { Foo<Int>::class } class...
# getting-started
m
Copy code
fun main() {
    Foo<Int>::class
}

class Foo<T>(val foo: T)
This results in a compiler error. How can I uniquely represent a generic type and a specific combination of type arguments? It’s okay for the workaround solution to be verbose; I want to make a compiler plugin.
c
Use
typeOf<Foo<Int>>()
, which gives a
KType
, which has all the information you want
m
Thank you!
c
Because
typeOf
is
inline reified
, it doesn't have the problem of erased type parameters. It's what KotlinX.Serialization uses to know what you want to deserialize, for example
m
That makes sense. I appreciate the explanation!