[Solved] A bug in the Kotlin compiler caused issue...
# arrow
d
[Solved] A bug in the Kotlin compiler caused issues with inline classes inside
crossinline suspend
functional parameters. Fixed in Kotlin 1.5.30-RC. Is it a known bug that
either {}
does not work properly with
value
classes? For example, the following code:
Copy code
@JvmInline
value class Metadata(val map: Map<String, String>)

fun reproduceBug() = either<Unit, Metadata>{
  Metadata(emptyMap())
}
Whenever I use debug to see the result of the function, it will contain a
Right({})
, meaning that the right value actually contains the underlying
Map
instead of the
Metadata
wrapper. This causes a
ClassCastException
in runtime when using
bind
. Am I missing something?
s
Hey @Dario Valdespino, Yes, that’s exactly what is happening since the
value class
doesn’t exist at runtime. IIRC this bug is related to
suspend
+
value class
and is “unrelated” to the encoding inside
either { }
. For this reason I’m currently not using
value class
yet in production (😞). So this is fixed in 1.5.30?
d
Yep, I had to update to the 1.5.30-RC but it works as expected
👍 1
s
Cool, thanks for the update. That version should be released before we release Arrow 1.0.0 soon 🙂
👍🏼 1