Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 321011

Summary: Unexpecter filter signature
Product: [Modeling] Acceleo Reporter: Ed Willink <ed>
Component: CoreAssignee: Project Inbox <acceleo-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: laurent.goubet
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Ed Willink CLA 2010-07-27 09:32:58 EDT
Surely filter just selects collection elements, so it does not change the collection kind, therefore Bag::filter => Bag.

This is particularly tricky given the lack of let diagnosis so

[let aFilteredBag : Bag(X) = anUnfilteredBag(X)]

gets no diagnosis.

Equally a filtered Set is surely still a Set.
Comment 1 Laurent Goubet CLA 2010-07-27 09:37:14 EDT
Sorry, but I couldn't understand either the issue or the expected resolution ... Could you elaborate on what Acceleo gets wrong and what you expect it to do?
Comment 2 Ed Willink CLA 2010-07-27 11:55:42 EDT
I would expect

Collection(T)::filter(Classifier) : Collection(T)
Bag(T)::filter(Classifier) : Bag(T)
OrderedSet(T)::filter(Classifier) : OrderedSet(T)
Sequence(T)::filter(Classifier) : Sequence(T)
Set(T)::filter(Classifier) : Set(T)

(Classifier is what might replace OclType one day).
Comment 3 Laurent Goubet CLA 2010-07-28 03:24:07 EDT
This is already what Acceleo does, filter doesn't alter collection types. What you ask us to do is to add explicitely the Bag::filter() : Bag and all three others instead of only Collection::filter() : Collection?
Comment 4 Ed Willink CLA 2010-07-28 03:37:06 EDT
I did

[let aFilteredBag : Bag(X) = anUnfilteredBag(X)]

and aFiteredBag was empty.

I did

[let aFilteredBag : Sequence(X) = anUnfilteredBag(X)]

and aFiteredBag was not empty!

This suggests that the signature of filter is as documented

Collection::filter() : Sequence
Comment 5 Laurent Goubet CLA 2010-07-28 03:52:04 EDT
I can't figure out why you're talking about the "filter" operation with what you write as expressions. I could only figure the issue (well, more "deduce" as I am not sure this is your actual problem) with your last comment about a documentation issue on the filter operation.

There's indeed an implementation error on my side, I always return a Sequence from the filter operation... which provoked the documentation error as I am not the one who wrote it.
Comment 6 Laurent Goubet CLA 2010-07-30 09:36:02 EDT
filter should no longer implicitly cast everything to a Sequence. The fix has been committed on HEAD and will be available for the next build.
Comment 7 Laurent Goubet CLA 2011-08-18 04:22:20 EDT
Closing our "resolved" and "verified" bugs.