I am getting some (what seems to me) strange behavior when using the + method in a generic case class (below). The bottom method works fine, but the top one gives me an error for addVal - type mismatch; found: DataT, required: String.
I assume what is going on here is the compiler has converted this.datum into a String and so wants to use the String.plus method, whereas I want it to use the Numeric.plus method. Normally it would default to using the Numeric.plus method when presented with two Numeric instances so I'm not quite sure why it isn't in this case.
case class SingleValue[DataT <: Numeric[DataT]] ( datum: DataT, ) { def addToDatumDoesntWork(addVal: DataT): SingleValue[DataT] = SingleValue[DataT](this.datum + addVal) def addToDatumWorks(addVal: DataT): SingleValue[DataT] = SingleValue[DataT](this.datum.plus(this.datum, addVal)) }