Ahmed Mourad
12/24/2020, 2:42 PMT , it is replaced with kotlin.Any, if it's of type T : List<*>, it's of type List<kotlin.Any>.
I know that type-erasure is a thing, but what if I want to get the generic type (T) where the type is generic, and the regular fq name when it is not? Is there a way to check if a type is a generic one?raulraja
12/25/2020, 10:41 AMisTypeVariable or similar method is availableraulraja
12/25/2020, 10:45 AMraulraja
12/25/2020, 10:46 AMA.identity(): A is generic even though the runtime would just have a Any?.identity(): Any? functionraulraja
12/25/2020, 10:47 AMis A then you need inline reified generics, those the compiler capture and are available tagged for runtime checksAhmed Mourad
12/25/2020, 11:48 AMI believe aThere existsor similar method is availableisTypeVariable
KotlinType#isCustomTypeVariable I guess this's the one you mean.
That is, the compiler knowsThe problem is I was again usingis generic even though the runtime would just have aA.identity(): AfunctionAny?.identity(): Any?
KotlinType#getJetTypeFqName and It would just return the upper bound of said generic type, does the type need to be inline reified in order for this to work?Ahmed Mourad
12/25/2020, 3:02 PMKotlinType#isTypeParameter and it does seem to do the trick, I'm then able to get the text of the generic type by simply calling KotlinType#toStringraulraja
12/25/2020, 10:35 PM