Skip to content

scala.collection.mutable.Set cannot generate schema #861

@iblislin

Description

@iblislin

Hi, I ran into this issue:

scala> import scala.collection.mutable
                                                                                                                                                                          
scala> import com.sksamuel.avro4s.AvroSchema
                                                                                                                                                                          
scala> AvroSchema[mutable.Set[Int]]
-- [E172] Type Error: ----------------------------------------------------------
1 |AvroSchema[mutable.Set[Int]]
  |                            ^
  |No given instance of type com.sksamuel.avro4s.SchemaFor[scala.collection.mutable.Set[Int]] was found for parameter schemaFor of method apply in object AvroSchema.
  |I found:
  |
  |    com.sksamuel.avro4s.SchemaFor.autoDerived[scala.collection.mutable.Set[Int]](
  |      /* missing */
  |        summon[scala.deriving.Mirror.Of[scala.collection.mutable.Set[Int]]]
  |    )
  |
  |But Failed to synthesize an instance of type scala.deriving.Mirror.Of[scala.collection.mutable.Set[Int]]:
  |     * trait Set is not a generic product because it is not a case class
  |     * trait Set is not a generic sum because it is not a sealed trait.
1 error found

Is it okay to add the support for mutable.Set in this package, or I should add my own encoder/decoder locally in my project codebase?

If it's fine to include it in this project, I can try to make a PR. (well, my Scala skill is rusty. :p)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions