I'm getting issues when trying to serialize a non-...
# arrow
e
I'm getting issues when trying to serialize a non-empty list using Jackson. (Arrow 2.1.0, Jackson 2.18.3)
1
Copy code
test("foo") {
         jacksonObjectMapper().registerKotlinModule().writeValueAsString(nonEmptyListOf("foo", "bar"))
      }

--> 

 
This is should be simple type: (Consumer<in (E..E?)>..Consumer<in (E..E?)>?)
java.lang.IllegalStateException: This is should be simple type: (Consumer<in (E..E?)>..Consumer<in (E..E?)>?)
	at kotlin.reflect.jvm.internal.impl.types.TypeSubstitutionKt.asSimpleType(TypeSubstitution.kt:205)
	at kotlin.reflect.jvm.internal.calls.ValueClassAwareCaller.<init>(ValueClassAwareCaller.kt:118)
	at kotlin.reflect.jvm.internal.calls.ValueClassAwareCallerKt.createValueClassAwareCallerIfNeeded(ValueClassAwareCaller.kt:333)
	at kotlin.reflect.jvm.internal.calls.ValueClassAwareCallerKt.createValueClassAwareCallerIfNeeded$default(ValueClassAwareCaller.kt:322)
	at kotlin.reflect.jvm.internal.KFunctionImpl.caller_delegate$lambda$4(KFunctionImpl.kt:103)
	at kotlin.reflect.jvm.internal.KFunctionImpl.accessor$KFunctionImpl$lambda1(KFunctionImpl.kt)
	at kotlin.reflect.jvm.internal.KFunctionImpl$$Lambda$1.invoke(Unknown Source)
	at kotlin.SafePublicationLazyImpl.getValue(LazyJVM.kt:122)
	at kotlin.reflect.jvm.internal.KFunctionImpl.getCaller(KFunctionImpl.kt:67)
	at kotlin.reflect.jvm.ReflectJvmMapping.getJavaMethod(ReflectJvmMapping.kt:64)
	at kotlin.reflect.jvm.ReflectJvmMapping.findKFunction(ReflectJvmMapping.kt:155)
	at kotlin.reflect.jvm.ReflectJvmMapping.getKotlinFunction(ReflectJvmMapping.kt:144)
	at com.fasterxml.jackson.module.kotlin.ReflectionCache.kotlinFromJava(ReflectionCache.kt:72)
Any ideas?
Maybe figured it out..? Think I was fooled by the comment here: https://github.com/arrow-kt/arrow-integrations/blob/main/arrow-integrations-jackso[…]rc/main/kotlin/arrow/integrations/jackson/module/ArrowModule.kt so I assumed no module for jackson was needed.. but now I see that there's a
NonEmptyCollectionsModule
in the code in the main repo 🙂
a
does it work when you add the new module? there's another known issue (https://github.com/arrow-kt/arrow/issues/3557) that affects some usages, but unfortunately can only be solved in the compiler side (I'm working on it)
e
Yeah I stumbled upon 3557 and assumed I would be affected too, since I have a
data class FooProblem(val bars: Nel<Bar>)
that I'm trying to serialize. I didn't bother pursuing it further at that point, but just dropped the Nel for a regular List. No chance it would work in my case, right? Great to see that it's being worked on! K