The following is a class structure for example purposes:
interface Target<V> {
val value: V
}
interface TargetBuilder<I, T : Target<I>> {
…
}
abstract class GenericTargetBuilder<I> : TargetBuilder<I, GenericTarget<I>> {
…
}
class A : GenericTargetBuilder<Int>() {
…
}
I would like to resolve GenericTarget<Int> from class A using kotlinpoet-ksp.
Following the docs, I tried the following:
- I do a tree search on the super types of class
A to find the first TypeReference of TargetBuilder.
- At this point, I have the
TypeReferences and TypeDeclarations of all the super types of class A.
- I take the second type argument (index 1) of the
TargetBuilder declaration on GenericTargetBuilder.
- Now, I call
toTypeName on the type argument type's TypeReference, passing in a recursive TypeParametersResolver (foldRight on all of the parent declarations’ type parameters, if any).
I get GenericTarget<I>, instead of the expected GenericTarget<Int>.
How should I go about resolving GenericTarget<Int> from this kind of class structure?
The following is a class structure for example purposes:
I would like to resolve
GenericTarget<Int>from classAusing kotlinpoet-ksp.Following the docs, I tried the following:
Ato find the firstTypeReferenceofTargetBuilder.TypeReferences andTypeDeclarations of all the super types of classA.TargetBuilderdeclaration onGenericTargetBuilder.toTypeNameon the type argument type'sTypeReference, passing in a recursiveTypeParametersResolver(foldRighton all of the parent declarations’ type parameters, if any).I get
GenericTarget<I>, instead of the expectedGenericTarget<Int>.How should I go about resolving
GenericTarget<Int>from this kind of class structure?