Skip to content

JsObject should return immutable collections (play-json 2.8/ scala 2.13) #388

@987Nabil

Description

@987Nabil

I was just migrating to scala 2.13 and realised, that the only collections related migration I had to do, was with JsObject. I was using this two fields

  /**
   * The fields of this JsObject in the order passed to the constructor
   */
  lazy val fields: collection.Seq[(String, JsValue)] = underlying.toSeq

  /**
   * The value of this JsObject as an immutable map.
   */
  lazy val value: Map[String, JsValue] = underlying match {
    case m: immutable.Map[String, JsValue] => m
    case m                                 => m.toMap
  }

What I found interesting is, that even the second comment says immutable map and underlying.toSeq is returning an immutable.Seq the return values are collection.Mapand collection.Seq. This seems odd to me. Especially because immutable collections should be considered the default, since it is what is defined in predef now (2.13).

Are there any good reasons to not change this to immutable?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions