fun serialize(aList: List<Any>)
When I call serialize with a List containing Symbol and Keyword, the compiler complains
type mismatch:
Require List<Any>
Found: List<Comparable<{Symbol & Keyword}>?>
Shouldn't List be covariant?
how can I construct a type signature to match what the compiler expects List<Comparable<{Symbol & Keyword}>?>
The compiler expects the type List<Comparable<{Symbol & Keyword}>?> but that is not valid kotlin syntax
You have to make
serialize()to acceptList<Any?>instead since yourComparabletype is nullable.If you want it to accept
List<Comparable<{Symbol & Keyword}>?>, you have to make use of where-clause to provide multiple upper bounds: