Closed SethTisue closed 4 years ago
This is an overloaded method. Since AnyRefMap
and LongMap
have no reason to exist save for performance, it's good to be able to use them in a high-performance fashion. This allows the familiar m += (key, value)
notation at full speed.
You can also (with any mutable map, and with these ones) do m(key) = value
to avoid tuples.
It's true that it's inconsistent with the move away from allowing multi-arg infix calls. I view this as an argument against that move, but if you take the necessity of the move as a given, then I agree that this has to go.
I was going to say, Ichoran had commented long ago on this particular issue, but I'd forgotten what his recommendation was for the idiom. I haven't searched for that previous judgment on some old issue.
I see there is specialized addOne(k, v)
to get this.type
back.
@SethTisue I don't mind submitting a quick deprecation in favor of addOne
if you like. IIUC that silences the deprecation? Or maybe not if it's a syntax warning.
For some reason, the multi-arg infix issue has yielded no "adderAll" puns.
@som-snytt Good idea! I guess we'll let Jenkins tell us if the enclosing-deprecation rule applies. I think you had a PR once that deferred checks until after typer?
@som-snytt sure, yes please (and LongMap
too). maybe it should suggest both addOne
and updated
?
@SethTisue OK that sounds like a plan! Let's do it!
e.g.
AnyRefMap
has:But the
+=
signature is inconsistent with other maps, where the method of the same name takes a tuple. It's also inconsistent with Scala's gradual move away from allowing multi-arg infix calls.This turned up in https://github.com/scala/scala/pull/8998, which increases the level of linting we do in
src/library
, resulting in: