[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:
@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?