I have a processor that creates KotlinPoet `TypeNa...
# ksp
f
I have a processor that creates KotlinPoet
TypeName
instances from
KType
values, using the
asTypeName()
extension to
KType
provided by KotlinPoet. Looks like the implementation of
asTypeName()
relies on
kotlin-reflect
(the
typeParameters
property on
KClass
). In KSP1, using
asTypeName()
like this works but with KSP2 I’m getting an exception:
Copy code
Caused by: kotlin.jvm.KotlinReflectionNotSupportedError: Kotlin reflection implementation is not found at runtime. Make sure you have kotlin-reflect.jar in the classpath
    at kotlin.jvm.internal.ClassReference.error(ClassReference.kt:88)
    at kotlin.jvm.internal.ClassReference.getTypeParameters(ClassReference.kt:38)
    at com.squareup.kotlinpoet.ParameterizedTypeName$Companion.get$kotlinpoet(ParameterizedTypeName.kt:236)
    at com.squareup.kotlinpoet.ParameterizedTypeNames.asTypeName(ParameterizedTypeName.kt:275)
My processor already includes
kotlin-reflect
as an implementation dependency – and I've tried adding it for the consumer of the processor too, but same failure. Running with latest KSP version but in legacy mode (via
useKsp2 = false
) works fine as well – so seems definitely an issue with KSP2. Anyone have any suggestions on other things I can try?
s
Same problem here when updating ksp
2.1.20-2.0.0
👀 1