Suppose a code like this: ```class Outer<T> ...
# ksp
y
Suppose a code like this:
Copy code
class 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
.
y
you want the type arguments of the KS Type. 1sec
ksType.arguments
in room we needed the declaration as well (KSTypeParameter) to resolve variance when generating java code
so you probably don't need it
y
Hmm... Since
Inner
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.
y
oh, hmm
didn't notice that part sorry
t
You don't need to resolve a type reference to get its type arguments.
Copy code
// 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.
y
Thank you. I'm looking forward to it being fixed!