Vladimir Tagakov
06/09/2022, 8:03 PMabstract class BaseClass<TypeParam>
abstract class IntermediateClass<TypeParam> : BaseClass<TypeParam>
@MyAnnotation class MyClass: IntermediateClass<String>
abstract class AnotherIntermediateClass: BaseClass<Int>
@MyAnnotation class AnotherMyClass: AnotherIntermediateClass
All classes having @MyAnnotation are extending BaseClass in one way or another. Can’t figure out how to get the types parametrizing BaseClass for MyClass and AnotherMyClass can someone help me here please?Vladimir Tagakov
06/09/2022, 9:49 PMBaseClass I wan’t to know what is the exact value of the type parameter in BaseClass despite of the class hierarchyJiaxiang
06/10/2022, 12:01 AMKSTypeArgument?Vladimir Tagakov
06/10/2022, 12:13 AM(myClass.superTypes.first()//returns IntermediateClass<String> (1)
.resolve() // (2)
.declaration as KSClassDeclaration)
.superTypes.first() //returns BaseClass<TypeParam> (3)
.resolve()
.arguments.first()//returns [INVARIANT TypeParam] not a [INVARIANT String]
I can get what you are saying at the (2) but at (3) the information is already gone.
Basically I am looking for the API similar to:
fun KSClassDeclaration.asMemberOfClassHierarchy(containing: KSType): KSType
So I will be able to do something like:
resolver.getClassDeclarationByName("com.BaseClass").asMemberOfClassHierarchy(myClassKSType).arguments //should have KSTypeArgument with [INVARIANT String]