Why do immutable.Set1/2/3/4 not implement StrictOptimizedSetOps?

In Scala 2.13 and Scala 3, the classes immutable.Set1, immutable.Set2, immutable.Set3, and immutable.Set4 implement StrictOptimizedIterableOps but not StrictOptimizedSetOps. The latter trait, defined in the same file as the four set classes, only adds an optimized version of concat.
This version returns this if the added elements are already included which is a welcome optimization.

So, shouldn’t these implementations of immutable.Set also implement StrictOptimizedSetOps like the other implementations?

1 Like

Hello @errt, thank you for your message. I think this is an oversight, these types should extend StrictOptimizedSetOps.
I guess doing so is still possible now since StrictOptimizedSetOps only overrides existing methods, so, the changes would be forward binary compatible, but that needs to be double-checked. Would you be interested in submitting a PR with this change?


@julienrf Thanks for your reply. I submitted a PR: Use StrictOptimizedSetOps in immutable.Set[1,2,3,4] by errt · Pull Request #10036 · scala/scala · GitHub