How can I create a KSTypeReference from a class?
# ksp
j
How can I create a KSTypeReference from a class?
j
and you can call
asStarProjectedType
or
asType()
to get a
KSType
from
KSClassDeclaration
j
So I have a KClass
This is in regards to trying to understand the generics api
I have an object that is known to implement X<Y,Z> and I want to get the values of Y and Z
I’m trying to get it by resolver.getTypeArgument and passing in the variance from the declaration.typeArguments, but the method on the resolver takes in a KSType and I just have a KClass of the known type
y
Are you interested in the bounds of Y/Z ? because, otherwise, they don't mean anything until you have a type referencing it
j
if you already have the
KClass
, then you can get the
KSClassDeclaration
by
resolver.getClassDeclarationByName(KClass.qualifiedName)
🙌 1
j
@yigit Yes the bounds. I have the object that has the specified values for Y and Z
I’ll give those extensions a look - thanks
502 Views