Kotlin enums definitely extend `java.lang.Enum`, c...
# announcements
k
Kotlin enums definitely extend
java.lang.Enum
, can you post your code and error message?
g
Apologies, I should have included "assumption" in that statement. I just couldn't get it to compile and, assumed. I'm trying to extend
org.neo4j.ogm.typeconversion.EnumConverter
which has the constructor
public EnumStringConverter(Class<? extends Enum> enumClass)
. This is as close as I've gotten, but still compile error:
Copy code
enum class MyEnum {
    ONE, TWO

    companion object
}

class MyEnumStringConverter : org.neo4j.ogm.typeconversion.EnumStringConverter(MyEnum.javaClass)
Compile error:
Error:(10, 97) Kotlin: Type inference failed. Expected type mismatch: inferred type is Class<SecurityType.Companion> but Class<out Enum<(raw) Enum<*>>!>! was expected
I tried first without the
MyEnum::class
instead of
MyEnum.javaClass
which gave this compiler error:
Error:(15, 80) Kotlin: Type mismatch: inferred type is KClass<MyEnum> but Class<out Enum<(raw) Enum<*>>!>! was expected
And
MyEnum
.. as well as all above with and without
companion object
So, how do I get a Kotlin enum's
Class<? extends java.lang.Enum>
? thanks!