-
Notifications
You must be signed in to change notification settings - Fork 660
Closed
Description
Is there a specific reason why Iterable<T>
cannot be serialized when it is a property, but it can be when it is serialized individually? When the type is specified as List<T>
instead of Iterable<T>
serialization does succeed.
The following tests all pass on v0.5.1:
@Test
fun `can serialize Iterable`()
{
val iterable: Iterable<Int> = listOf( 1 )
val serialized = JSON.stringify( PolymorphicSerializer, iterable )
}
@Serializable
data class ContainsIterable( val list: Iterable<Int> )
@Test
fun `cannot serialize Iterable as a property`()
{
val iterableList = ContainsIterable( listOf( 1 ) )
assertFailsWith<NoSuchMethodError>
{
val serialized = JSON.stringify( iterableList )
}
}
@Serializable
data class ContainsList( val list: List<Int> )
@Test
fun `can serialize List as a property`()
{
val list = ContainsList( listOf( 1 ) )
val serialized = JSON.stringify( list )
}