I have the following trait:
trait SomeTrait {
def doSomething[V](msg: Message[V]): Message[V]
}
The Message[V] is a case class as below:
case class Message[V](elems: Map[String, V])
I now have a method that calls the doSomething method as below:
val someWork = new SomeTrait {
override def doSomething[Int](msg: Message[Int]): Message[Int] = {
msg.copy(elems = msg.elems.map {
case (k, v) => (k, v + 1) // It fails here!!!
})
}
}
I get a strange compiler error saying that:
Error:(16, 32) type mismatch;
found : Int(1)
required: String
Error occurred in an application involving default arguments.
case (k, v) => (k, v + 1)
Was I stupid somewhere?