-
Notifications
You must be signed in to change notification settings - Fork 72
Conversation
if x % 2 == 0 | ||
} yield x + 1 | ||
val xs1t: TreeSet[Int] = xs1 | ||
assert(xs1 == TreeSet(3)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test fails on Dotty. This is probably something related to hashcodes. We observed a weird behavior here too. I’ll create an issue in Dotty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Dotty xs1 == TreeSet()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually that’s not related to hashcodes, but maybe to inlining in Dotty. I added a commit that un-inlines some methods and now the tests pass on Dotty. I’m trying to minimize the problem.
I agree this looks pretty bad but I haven't had time to come up with anything better, if it's even possible to come up with something better. Is it possible to simply not provide a default implementation for the difficult cases? If we were worrying about CBF, something with five type parameters is not going to go over well. |
What do you mean by “not provide a default implementation”? If we remove the complex subclasses of In my opinion, the PR is fine to merge, these complex classes are not aimed to be manipulated by end-users. |
I mean that we manually write the |
For |
Yes, but we don't have that many map collection types. Anyway, it's not a very satisfying answer, but it's the best idea I have right now (aside from the scheme you already came up with). |
I wonder, why is the implementation in the existing collections so much simpler? What do they do that we cannot? CBF? |
I haven't had time to work this all the way through, but it seems to me if the I haven't yet had time to play with making |
@Ichoran I’m trying something with Without |
I don't think there's anything wrong with four kinds of |
OK, I see. I’ll experiment with that tomorrow. |
This started nicely. But then… things got worse when it was time to support sorted and Map collections.
I used Views to implement
WithFilter
. I noticed that in the current collectionswithFilter
calls are fused, so I implementedfilter
fusion on Views too.That’s it for the nice part.
Now, what’s the problem with Map and sorted collections? The implementation of
WithFilter
delegates toiterableFactory
to build the collection resulting of amap
orflatMap
call subsequent towithFilter
. However, in the case ofMap
,iterableFactory
builds anIterable
instead of the expected concreteMap
, and in the case ofSortedSet
,iterableFactory
builds aSet
instead of the expected concreteSortedSet
. Consequently, I created subclasses ofWithFilter
for each case (SortedWithFilter
,MapWithFilter
andSortedMapWithFilter
). Then, I refined thewithFilter
member inMap
,SortedSet
andSortedMap
to return the corresponding specializedXxxWithFilter
. Since this is a refinement, it means that all of theseXxxWithFilter
classes have to extend the initialWithFilter
class (in the same way that all collection types extendIterable
). I’m not happy with the result because there are lots of parameters and type parameters. However, I don’t have a better solution :(Fixes #145.