yamasa
02/19/2021, 4:49 PMclass Outer<T> {
inner class Inner
}
val foo: Outer<String>.Inner
get() = TODO()
Is there a way to get the type argument String
from KSPropertyDeclaration.type
of the property foo
?
I tried fooPropertyDeclaration.type.resolve().declaration.parentDeclaration?.typeParameters?.get(0)
, but it was T
, not String
.yigit
02/19/2021, 4:50 PMyigit
02/19/2021, 4:50 PMksType.arguments
yigit
02/19/2021, 4:51 PMyigit
02/19/2021, 4:51 PMyamasa
02/19/2021, 4:56 PMInner
itself has no type parameter, fooPropertyDeclaration.type.resolve().arguments
is empty.
I'd like to access the ksType
of Outer
, but I don't know how to do it.yigit
02/19/2021, 4:57 PMyigit
02/19/2021, 4:57 PMTing-Yuan Huang
02/19/2021, 6:39 PM// returns String
(fooPropertyDeclaration.type.element as KSClassifierReference).qualifier.typeArguments
On the other hand, it looks like a bug to me that the KSType
for Inner
has no type argument. Unlike nested types, inner types should carry type arguments from their outer types.Ting-Yuan Huang
02/19/2021, 6:49 PMyamasa
02/20/2021, 3:33 AM