scalaplayframework-2.3

Scala play; pattern matching on Map; cannot resolve Map.unapply


I use scala play framework and have this simple template:

@defining({
    Map("a" -> 1, "b" -> 2)
}) { case Map("a" -> aValue, *) =>
    <div>
        this is a value: @a
    </div>
}

IntelliJ Idea underlines Map in case Map(..., saying that it "Cannot resolve method Map.unapply" and that it also "Cannot resolve symbol Map".

Changing the implementation from Map to List or Seq makes the red underline go away, but I'd like to use a structure that's searchable by key and its items are order-independent. Any ideas how make the pattern matching work on Map with Scala Play inside defining block?


Solution

  • According to API docs Map does not have unapplySeq method and thus cannot be pattern matched out-of-the-box. You could try adding your own as suggested here.