given a `KSType`, how can I tell if it is an enum?...
# ksp
w
given a
KSType
, how can I tell if it is an enum? i’m looking into obtaining a
KSClassDeclaration
for
Enum<*>
I have this, but it isn’t working yet
Copy code
private val enumType = resolver.getClassDeclarationByName(resolver.getKSNameFromString("kotlin.Enum")) ?: error("Cannot find kotlin.Enum KSName")

type.isAssignableFrom(enumType.asStarProjectedType()) // always returns false when type is an enum class
oops looks like i had it flipped
enumType.asStarProjectedType().isAssignableFrom(type)
works 🙂
👍 1
t
Have you tried
KSClassDeclaration.classKind
?
181 Views