Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scalac warns about "match may not be exhaustive" for specific record with map type #166

Open
mkuthan opened this issue Mar 17, 2023 · 0 comments

Comments

@mkuthan
Copy link

mkuthan commented Mar 17, 2023

If project defines restrictive Scala flags like -Xfatal-warnings the compilation of generated specific records fail if there is a map in the schema.

SampleAvroClass.scala:69:9: match may not be exhaustive.
It would fail on the following input: (x: Any forSome x not in java.util.Map[?,?])

Corresponding fragment of the generated specific record:

case 4 => this.mapField = {
  value match {
    case (map: java.util.Map[_,_]) => {
      scala.jdk.CollectionConverters.MapHasAsScala(map).asScala.toMap map { kvp =>
        val key = kvp._1.toString
        val value = kvp._2
        (key, value.toString)
      }
    }
  }
}.asInstanceOf[Map[String, String]]

I would opt for adding unchecked annotation in the generated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant