Compiler plugin question: How do I get the type p...
# compiler
j
Compiler plugin question: How do I get the type parameters of an property like
List<SomeType>
as
IrType
? I tried
backingField!!.type.originalKotlinType!!.arguments
, but I don't know how to get from a
TypeProjection
to an
IrType
...
s
You can try .type or just cast projection to type
j
I had to cast first, to get to the
arguments
. This is the helper I came up with
Copy code
private val IrProperty.typeArguments: List<IrType>
    get() {
      val asSimpleType = backingField!!.type as IrSimpleType
      return asSimpleType.arguments.map { it.typeOrNull!! }
    }